QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#235156#6643. Graphs and Colorsjzh#WA 0ms3620kbC++201.6kb2023-11-02 15:21:472023-11-02 15:21:47

Judging History

This is the latest submission verdict.

  • [2023-11-02 15:21:47]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3620kb
  • [2023-11-02 15:21:47]
  • Submitted

answer

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

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


    while (t--) {
        ll n, k;
        cin >> n >> k;
        vector<vector<int>> block(n, vector<int>(n));
        vector<pair<ll, pii>> op;
        int cnt3 = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if ((i + j) % 2 == 0) {
                    block[i][j] = 1;
                    int cnt = 4;
                    if (i == 0 || i == n - 1)cnt--;
                    if (j == 0 || j == n - 1)cnt--;
                    op.push_back({cnt, {i, j}});
                    cnt3 += (cnt == 3);
                }
            }
        }
        sort(op.begin(), op.end());
        reverse(op.begin(), op.end());
        ll num = 2LL * n * (n - 1) - k;
        for (auto [cnt, pos]: op) {
            if (num - cnt != 1 && num >= cnt) {
                if (cnt == 3) {
                    cnt3--;
                    if (cnt3 == 0 && (num - cnt) % 2 == 1)continue;
                }
                num -= cnt;
                block[pos.first][pos.second] = 0;
            }
        }

        if (num != 0) {
            cout << "Impossible\n";
        } else {

            cout << "Possible\n";

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    cout << (block[i][j] ? 'R' : 'B');
                }
                cout << "\n";
            }

        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3620kb

input:

768
8 24
7 20
17 61
17 76
16 100
16 16
15 59
9 17
14 31
14 61
10 32
17 55
5 7
10 29
14 82
13 47
17 32
5 10
16 76
14 59
8 28
13 19
12 41
13 41
11 32
11 53
3 2
16 52
16 87
7 12
9 15
15 65
15 53
17 47
6 15
12 1
14 35
16 60
12 31
14 70
15 88
12 2
8 23
12 38
16 111
16 117
5 4
14 90
12 55
15 41
15 48
15 4...

output:

Possible
BBRBRBRB
BBBBBBBR
RBBBBBBB
BBBBBBBR
RBBBBBBB
BBBBBBBR
BBBBBBBB
BBBBBBBB
Possible
RBRBRBR
BBBBBBB
RBBBBBR
BBBBBBB
BBBBBBB
BBBBBBB
RBBBBBR
Possible
RBRBRBRBRBRBRBRBR
BBBBBBBBBBBBBBBBB
RBBBBBBBBBBBBBBBR
BBBBBBBBBBBBBBBBB
RBBBBBBBBBBBBBBBR
BBBBBBBBBBBBBBBBB
RBBBBBBBBBBBBBBBR
BBBBBBBBBBBBBBBBB
R...

result:

wrong answer Coloring is not possible but participant does not prints no (test case 1)