QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#229373#7637. Exactly Three Neighborsucup-team1198#AC ✓5ms3528kbC++202.3kb2023-10-28 16:00:382023-10-28 16:00:38

Judging History

你现在查看的是最新测评结果

  • [2023-10-28 16:00:38]
  • 评测
  • 测评结果:AC
  • 用时:5ms
  • 内存:3528kb
  • [2023-10-28 16:00:38]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define pii pair<int, int>
#define ld long double
#define all(a) (a).begin(), (a).end()

void print(int k) {
    cout << 3 * k + 2 << " " << 3 * k + 2 << "\n";
    vector<string> ans(3 * k + 2, string(3 * k + 2, '#'));
    for (int i = 0; i < k; ++i) {
        int x = -500 + i, y = 0;
        for (int a = 0; a < 1000; ++a) {
            for (int b = 0; b < 1000; ++b) {
                int x1 = x + a * (k + 1) + b * k;
                int y1 = y + a - 2 * b;
                if (x1 >= 0 && x1 < 3 * k + 2 && y1 >= 0 && y1 < 3 * k + 2) {
                    ans[x1][y1] = '.';
                }
            }
        }
    }
    for (auto s : ans) {
        cout << s << "\n";
    }
}

void col(int x, int y, vector<string>& ans) {
    for (int a = 0; a < 1000; ++a) {
        for (int b = 0; b < 1000; ++b) {
            int x1 = x + a * 6 + b * 5;
            int y1 = y + b * 3;
            if (x1 >= 0 && x1 < (int)ans.size() && y1 >= 0 && y1 < (int)ans[0].size()) {
                ans[x1][y1] = '.';
            }
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    /**for (int p1 = 1; p1 <= 10; ++p1) {
    for (int q1 = 1; q1 <= 10; ++q1) {*/


    int p, q;
    /// p = p1;
    /// q = q1;
    cin >> p >> q;
    int d = __gcd(p, q);
    p /= d;
    q /= d;

    /// if (d != 1) continue;

    /// cout << p << ' ' << q << ":\n";

    if (p * 3 <= q * 2) {
        cout << 1 << " " << 2 * q << "\n";
        string s(2 * q, '.');
        for (int i = 0; i < p; ++i) {
            s[3 * i] = s[3 * i + 1] = '#';
        }
        cout << s << "\n";
        return 0;
        /// continue;
    }
    if (p * 5 > q * 4) {
        cout << "-1 -1\n";
        return 0;
        /// continue;
    }

    if (p == 3 && q == 4) {
        print(2);
    } else if (p == 4 && q == 5) {
        print(1);
    } else if (p == 5 && q == 7) {
        print(4);
    } else if (p == 7 && q == 10) {
        print(6);
    } else if (p == 7 && q == 9){
        cout << "6 18\n";
        vector<string> ans(6, string(18, '#'));
        col(-500, 0, ans);
        col(-499, 0, ans);
        col(-497, -1, ans);
        col(-495, -2, ans);
        for (auto s : ans) {
            cout << s << "\n";
        } 
    } else {
        cout << "-1 -1\n";
    }

    /// }}

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3516kb

input:

2 3

output:

1 6
##.##.

result:

ok good solution

Test #2:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

1 1

output:

-1 -1

result:

ok no solution

Test #3:

score: 0
Accepted
time: 2ms
memory: 3428kb

input:

3 4

output:

8 8
#.##.###
####.##.
##.####.
##.##.##
.####.##
.##.####
###.##.#
#.####.#

result:

ok good solution

Test #4:

score: 0
Accepted
time: 1ms
memory: 3528kb

input:

3 5

output:

1 10
##.##.##..

result:

ok good solution

Test #5:

score: 0
Accepted
time: 1ms
memory: 3528kb

input:

4 5

output:

5 5
.####
###.#
#.###
####.
##.##

result:

ok good solution

Test #6:

score: 0
Accepted
time: 5ms
memory: 3464kb

input:

7 10

output:

20 20
.####.##.##.##.##.##
.##.####.##.##.##.##
.##.##.####.##.##.##
.##.##.##.####.##.##
.##.##.##.##.####.##
.##.##.##.##.##.####
###.##.##.##.##.##.#
#.####.##.##.##.##.#
#.##.####.##.##.##.#
#.##.##.####.##.##.#
#.##.##.##.####.##.#
#.##.##.##.##.####.#
#.##.##.##.##.##.###
####.##.##.##.##.##.
...

result:

ok good solution

Test #7:

score: 0
Accepted
time: 0ms
memory: 3412kb

input:

5 7

output:

14 14
##.####.##.##.
##.##.####.##.
##.##.##.####.
##.##.##.##.##
.####.##.##.##
.##.####.##.##
.##.##.####.##
.##.##.##.####
###.##.##.##.#
#.####.##.##.#
#.##.####.##.#
#.##.##.####.#
#.##.##.##.###
####.##.##.##.

result:

ok good solution

Test #8:

score: 0
Accepted
time: 0ms
memory: 3412kb

input:

7 9

output:

6 18
##.####.####.##.##
####.####.##.####.
#.####.##.####.###
###.##.####.####.#
.##.####.####.####
.####.####.####.##

result:

ok good solution

Test #9:

score: 0
Accepted
time: 0ms
memory: 3464kb

input:

0 1

output:

1 2
..

result:

ok good solution

Test #10:

score: 0
Accepted
time: 0ms
memory: 3484kb

input:

1 2

output:

1 4
##..

result:

ok good solution

Test #11:

score: 0
Accepted
time: 1ms
memory: 3384kb

input:

1 3

output:

1 6
##....

result:

ok good solution

Test #12:

score: 0
Accepted
time: 1ms
memory: 3452kb

input:

1 4

output:

1 8
##......

result:

ok good solution

Test #13:

score: 0
Accepted
time: 0ms
memory: 3420kb

input:

1 5

output:

1 10
##........

result:

ok good solution

Test #14:

score: 0
Accepted
time: 0ms
memory: 3496kb

input:

1 6

output:

1 12
##..........

result:

ok good solution

Test #15:

score: 0
Accepted
time: 1ms
memory: 3528kb

input:

1 7

output:

1 14
##............

result:

ok good solution

Test #16:

score: 0
Accepted
time: 1ms
memory: 3452kb

input:

1 8

output:

1 16
##..............

result:

ok good solution

Test #17:

score: 0
Accepted
time: 1ms
memory: 3436kb

input:

1 9

output:

1 18
##................

result:

ok good solution

Test #18:

score: 0
Accepted
time: 0ms
memory: 3464kb

input:

1 10

output:

1 20
##..................

result:

ok good solution

Test #19:

score: 0
Accepted
time: 0ms
memory: 3424kb

input:

2 5

output:

1 10
##.##.....

result:

ok good solution

Test #20:

score: 0
Accepted
time: 0ms
memory: 3440kb

input:

2 7

output:

1 14
##.##.........

result:

ok good solution

Test #21:

score: 0
Accepted
time: 0ms
memory: 3488kb

input:

2 9

output:

1 18
##.##.............

result:

ok good solution

Test #22:

score: 0
Accepted
time: 0ms
memory: 3400kb

input:

3 7

output:

1 14
##.##.##......

result:

ok good solution

Test #23:

score: 0
Accepted
time: 0ms
memory: 3384kb

input:

3 8

output:

1 16
##.##.##........

result:

ok good solution

Test #24:

score: 0
Accepted
time: 0ms
memory: 3400kb

input:

3 10

output:

1 20
##.##.##............

result:

ok good solution

Test #25:

score: 0
Accepted
time: 0ms
memory: 3400kb

input:

4 7

output:

1 14
##.##.##.##...

result:

ok good solution

Test #26:

score: 0
Accepted
time: 0ms
memory: 3484kb

input:

4 9

output:

1 18
##.##.##.##.......

result:

ok good solution

Test #27:

score: 0
Accepted
time: 0ms
memory: 3448kb

input:

5 6

output:

-1 -1

result:

ok no solution

Test #28:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

5 8

output:

1 16
##.##.##.##.##..

result:

ok good solution

Test #29:

score: 0
Accepted
time: 0ms
memory: 3416kb

input:

5 9

output:

1 18
##.##.##.##.##....

result:

ok good solution

Test #30:

score: 0
Accepted
time: 0ms
memory: 3488kb

input:

6 7

output:

-1 -1

result:

ok no solution

Test #31:

score: 0
Accepted
time: 0ms
memory: 3412kb

input:

7 8

output:

-1 -1

result:

ok no solution

Test #32:

score: 0
Accepted
time: 1ms
memory: 3384kb

input:

8 9

output:

-1 -1

result:

ok no solution

Test #33:

score: 0
Accepted
time: 0ms
memory: 3460kb

input:

9 10

output:

-1 -1

result:

ok no solution

Extra Test:

score: 0
Extra Test Passed