QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#594095#7637. Exactly Three Neighborsucup-team3519#WA 0ms3872kbC++171.7kb2024-09-27 19:08:312024-09-27 19:08:32

Judging History

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

  • [2024-09-27 19:08:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3872kb
  • [2024-09-27 19:08:31]
  • 提交

answer

#include <bits/stdc++.h>

void output(int n, int m, std::vector<std::pair<int, int>> arr) {

    std::cout << n << ' ' << m << '\n';
    
    std::vector<std::string> ans(n, std::string(m, '#'));
    for (auto [x, y] : arr) {
        ans[x - 1][y - 1] = '.';
    }

    for (int i = 0; i < n; ++i) {
        std::cout << ans[i] << '\n';
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int p, q;
    std::cin >> p >> q;

    // if (p / q > 4 / 5)
    if (p * 5 > 4 * q) {
        std::cout << "-1 -1\n";
        return 0;
    }

    // if (p / q <= 2 / 3)
    if (p * 3 <= 2 * q) {
        int row_b = p * 2;
        int row_w = (q - p) * 2;
        if (row_b % 4 == 0) {
            row_b /= 2;
            row_w /= 2;
        }

        std::string ans;
        while (row_b) {
            ans += "##.";
            row_b -= 2;
            row_w -= 1;
        }
        while (row_w) {
            ans += ".";
            row_w--;
        }

        std::cout << 1 << ' ' << ans.size() << '\n';
        std::cout << ans << '\n';
        return 0;
    }

    if (p == 4 && q == 5) {
        output(5, 5, {{1, 5}, {2, 3}, {3, 1}, {4, 4}, {5, 2}});
        return 0;
    }
    if (p == 5 && q == 7) {
        std::cout << "-1 -1\n";
        return 0;
    }
    if (p == 7 && q == 9) {
        std::cout << "-1 -1\n";
        return 0;
    }
    if (p == 7 && q == 10) {
        std::cout << "-1 -1\n";
        return 0;
    }
    if (p == 3 && q == 4) {
        output(8, 8, {{1, 7}, {1, 8}, {2, 4}, {2, 5}, {3, 1}, {3, 2}, {4, 6}, {4, 7}, {5, 3}, {5, 4}, {6, 1}, {6, 8}, {7, 5}, {7, 6}, {8, 2}, {8, 3}});
        return 0;
    }

    assert(false);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3624kb

input:

2 3

output:

1 3
##.

result:

ok good solution

Test #2:

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

input:

1 1

output:

-1 -1

result:

ok no solution

Test #3:

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

input:

3 4

output:

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

result:

ok good solution

Test #4:

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

input:

3 5

output:

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

result:

ok good solution

Test #5:

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

input:

4 5

output:

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

result:

ok good solution

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 3544kb

input:

7 10

output:

-1 -1

result:

wrong answer you didn't find a solution but jury did