QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#114079 | #6644. Red Black Grid | propane | WA | 22ms | 3560kb | C++20 | 2.2kb | 2023-06-20 21:25:59 | 2023-06-20 21:26:00 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
using LL = long long;
int main(){
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int T;
cin >> T;
while(T--){
int n, k;
cin >> n >> k;
auto solve = [&](int target){
int sum = n * (n - 1) * 2;
vector<vector<int> > a(n, vector<int>(n));
vector<pair<int, int> > v[5];
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if ((i + j) % 2 == target){
a[i][j] = 1;
int t = 4 - (i == 0 || i == n - 1) - (j == 0 || j == n - 1);
v[t].push_back({i, j});
}
}
}
for(int i = 0; i <= v[2].size(); i++){
for(int j = 0; j <= v[3].size(); j++){
int need = sum - k - 2 * i - 3 * j;
if (need % 4 == 0 && need >= 0 && need / 4 <= v[4].size()){
for(int t = 0; t < i; t++){
auto [x, y] = v[2][t];
a[x][y] = 0;
}
for(int t = 0; t < j; t++){
auto [x, y] = v[3][t];
a[x][y] = 0;
}
for(int t = 0; t < need / 4; t++){
auto [x, y] = v[4][t];
a[x][y] = 0;
}
cout << "Possible" << '\n';
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
cout << (a[i][j] ? 'R' : 'B');
}
cout << '\n';
}
return true;
}
}
}
return false;
};
if (!solve(0) && !solve(1)){
cout << "Impossible" << '\n';
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3416kb
input:
2 3 6 3 1
output:
Possible BBR BBB RBR Impossible
result:
ok correct! (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 22ms
memory: 3560kb
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 R Possible RB BR Impossible Possible BB BR Impossible Possible BB BB Possible RBR BRB RBR Impossible Possible BBR BRB RBR Possible BBB RBR BRB Possible RBR BBB RBR Impossible Possible BBR BBB RBR Impossible Possible BBB BBB RBR Possible BBB BBB BRB Possible BBB BBB BBR Impossible Possible B...
result:
wrong answer Condition failed: "A == B" (test case 12)