QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#122578 | #6644. Red Black Grid | installb# | WA | 2ms | 3412kb | C++14 | 1.9kb | 2023-07-10 19:30:35 | 2023-07-10 19:31:49 |
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 << "BRB\n";
cout << "BBB\n";
cout << "BBB\n";
return;
}
if(k == 5){
cout << "BRB\n";
cout << "BBB\n";
cout << "BBR\n";
return;
}
if(k == 7){
cout << "BRB\n";
cout << "BBB\n";
cout << "RBR\n";
return;
}
if(k == 9){
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 << "NO\n";
return;
}
cout << "YES\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: 0
Wrong Answer
time: 2ms
memory: 3412kb
input:
2 3 6 3 1
output:
YES BBB BRB BBR NO
result:
wrong answer Condition failed: "A == B" (test case 1)