QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#122596 | #6644. Red Black Grid | installb# | WA | 59ms | 3532kb | C++14 | 2.0kb | 2023-07-10 19:48:17 | 2023-07-10 19:48:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[2005][2005];
void solve(){
int n,k;
vector <pair <int,pair <int,int> > > G;
cin >> n >> k;
// special judge for N=3
if(n == 3){
if(k == 3){
cout << "Possible\n";
cout << "BRB\n";
cout << "BBB\n";
cout << "BBB\n";
return;
}
if(k == 5){
cout << "Possible\n";
cout << "BRB\n";
cout << "BBB\n";
cout << "BBR\n";
return;
}
if(k == 7){
cout << "Possible\n";
cout << "BRB\n";
cout << "BBB\n";
cout << "RBR\n";
return;
}
if(k == 9){
cout << "Possible\n";
cout << "BRB\n";
cout << "RBR\n";
cout << "BBB\n";
return;
}
}
for(int i = 1;i <= n;i ++){
for(int j = (i & 1) ? 1 : 2;j <= n;j += 2){
if(i == 1 || j == 1 || i == n || j == n){
if((i == 1 && j == 1) || (i == n && j == n) || (i == 1 && j == n) || (i == n && j == 1)) G.push_back({2,{i,j}});
else G.push_back({3,{i,j}});
}
else G.push_back({4,{i,j}});
}
}
sort(G.begin(),G.end());
reverse(G.begin(),G.end());
for(int i = 1;i <= n;i ++){
for(int j = 1;j <= n;j ++){
a[i][j] = 0;
}
}
for(auto [v,p] : G){
auto [x,y] = p;
if(k - v == 1 || k - v < 0) continue;
k -= v; a[x][y] = 1;
}
if(k != 0){
cout << "Impossible\n";
return;
}
cout << "Possible\n";
for(int i = 1;i <= n;i ++){
for(int j = 1;j <= n;j ++){
cout << (a[i][j] ? 'R' : 'B');
}
cout << '\n';
}
}
int main(){
ios::sync_with_stdio(false);
int TC;
cin >> TC;
while(TC --){
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3400kb
input:
2 3 6 3 1
output:
Possible BBB BRB BBR Impossible
result:
ok correct! (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 59ms
memory: 3532kb
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 RB BR Impossible Possible BB BR Impossible Possible BB BB Possible RBR BRB RBR Impossible Possible BBR BRB RBR Possible BRB RBR BBB Possible BBB BRB RBR Possible BRB BBB RBR Possible BBB BRB BBR Possible BRB BBB BBR Possible BBB BRB BBB Possible BRB BBB BBB Possible BBB BBB BBR I...
result:
wrong answer Condition failed: "A == B" (test case 48)