QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#119001 | #6644. Red Black Grid | 8BQube# | WA | 10ms | 3460kb | C++20 | 2.5kb | 2023-07-04 18:25:55 | 2023-07-04 18:25:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(), v.end()
#define pb push_back
string ans[1005];
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
if (n == 1) {
cout << "Possible\nB\n";
continue;
}
if (k == 1 || k == 2 * n * (n - 1) - 1) {
cout << "Impossible\n";
continue;
}
if (n == 2) {
if (k & 1) cout << "Impossible\n";
else if (k == 0) cout << "Possible\nBB\nBB\n";
else if (k == 2) cout << "Possible\nBR\nBB\n";
else if (k == 4) cout << "Possible\nBR\nRB\n";
else assert(0);
continue;
}
for (int i = 0; i < n; ++i) ans[i] = string(n, 'B');
if (k == 0)
ans[0][0] = 'B';
else if (k == 2)
ans[0][0] = 'R';
else if (k == 3)
ans[0][0] = ans[0][1] = 'R';
else if (k == 4)
ans[0][0] = ans[n - 1][n - 1] = 'R';
else if (k == 5)
ans[0][1] = ans[n - 1][n - 1] = 'R';
else {
for (int i = 0; i < n; ++i)
for (int j = (i & 1) ^ 1; j < n; j += 2)
ans[i][j] = 'R';
int cur = 2 * n * (n - 1);
if (k & 1) ans[0][1] = 'B', k -= 3;
vector<pii> coord[5];
auto pop = [&](int d) {
cur -= d;
auto [x, y] = coord[d].back();
coord[d].pop_back();
ans[x][y] = 'R';
};
for (int i = 0; i < n; ++i)
for (int j = i & 1; j < n; j += 2) {
if ((k & 1) && i + abs(j - 1) == 1) continue;
int cnt = 4;
if (i == 0) --cnt;
if (i == n - 1) --cnt;
if (j == 0) --cnt;
if (j == n - 1) --cnt;
coord[cnt].pb(pii(i, j));
}
while (cur - k >= 6 && SZ(coord[3]) >= 2)
pop(3), pop(3);
while (cur - k >= 4 && SZ(coord[4]) >= 1)
pop(4);
while (cur - k >= 2 && SZ(coord[2]) >= 1)
pop(2);
assert(cur == k);
}
cout << "Possible\n";
for (int i = 0; i < n; ++i) cout << ans[i] << "\n";
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3460kb
input:
2 3 6 3 1
output:
Possible BRB RRR BRR Impossible
result:
ok correct! (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 10ms
memory: 3440kb
input:
4424 1 0 2 4 2 3 2 2 2 1 2 0 3 12 3 11 3 10 3 9 3 8 3 7 3 6 3 5 3 4 3 3 3 2 3 1 3 0 4 24 4 23 4 22 4 21 4 20 4 19 4 18 4 17 4 16 4 15 4 14 4 13 4 12 4 11 4 10 4 9 4 8 4 7 4 6 4 5 4 4 4 3 4 2 4 1 4 0 5 40 5 39 5 38 5 37 5 36 5 35 5 34 5 33 5 32 5 31 5 30 5 29 5 28 5 27 5 26 5 25 5 24 5 23 5 22 5 21 5...
output:
Possible B Possible BR RB Impossible Possible BR BB Impossible Possible BB BB Possible BRB RBR BRB Impossible Possible BRB RBR BRR Possible BBB RRR BRR Possible BRB RRR BRB Possible BBB RRR RRR Possible BRB RRR BRR Possible BRB BBB BBR Possible RBB BBB BBR Possible RRB BBB BBB Possible RBB BBB BBB I...
result:
wrong answer Condition failed: "getNum(vec) == k" (test case 10)