QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#127381 | #6644. Red Black Grid | yy_zq# | WA | 45ms | 3464kb | C++14 | 3.8kb | 2023-07-19 16:37:18 | 2023-07-19 16:37:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,j,k) for(int i=j;i<=k;++i)
char a[1011][1011];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--){
int n,k;
cin>>n>>k;
if(n==1){
cout<<"Possible"<<endl;
cout<<"R"<<endl;
}
if(n==2){
if(k==0){
cout<<"Possible"<<endl;
cout<<"RR"<<endl;
cout<<"RR"<<endl;
}
if(k==1){
cout<<"Impossible"<<endl;
continue;
}
if(k==2){
cout<<"Possible"<<endl;
cout<<"RB"<<endl;
cout<<"RR"<<endl;
}
if(k==3){
cout<<"Impossible"<<endl;
continue;
}
if(k==4){
cout<<"Possible"<<endl;
cout<<"RB"<<endl;
cout<<"BR"<<endl;
}
}
if(n==3){
if(k==0){
cout<<"Possible"<<endl;
cout<<"RRR"<<endl;
cout<<"RRR"<<endl;
cout<<"RRR"<<endl;
}
if(k==1){
cout<<"Impossible"<<endl;
continue;
}
if(k==2){
cout<<"Possible"<<endl;
cout<<"BRR"<<endl;
cout<<"RRR"<<endl;
cout<<"RRR"<<endl;
}
if(k==3){
cout<<"Possible"<<endl;
cout<<"RBR"<<endl;
cout<<"RRR"<<endl;
cout<<"RRR"<<endl;
}
if(k==4){
cout<<"Possible"<<endl;
cout<<"RRR"<<endl;
cout<<"RBR"<<endl;
cout<<"RRR"<<endl;
}
if(k==5){
cout<<"Possible"<<endl;
cout<<"BRR"<<endl;
cout<<"RRB"<<endl;
cout<<"RRR"<<endl;
}
if(k==6){
cout<<"Possible"<<endl;
cout<<"RBR"<<endl;
cout<<"RRB"<<endl;
cout<<"RRR"<<endl;
}
if(k==7){
cout<<"Possible"<<endl;
cout<<"BRR"<<endl;
cout<<"RRB"<<endl;
cout<<"BRR"<<endl;
}
if(k==8){
cout<<"Possible"<<endl;
cout<<"BRB"<<endl;
cout<<"RRR"<<endl;
cout<<"BRB"<<endl;
}
if(k==9){
cout<<"Possible"<<endl;
cout<<"RBR"<<endl;
cout<<"BRB"<<endl;
cout<<"RRR"<<endl;
}
if(k==10){
cout<<"Possible"<<endl;
cout<<"RBR"<<endl;
cout<<"BRB"<<endl;
cout<<"RBB"<<endl;
}
if(k==11){
cout<<"Impossible"<<endl;
continue;
}
if(k==12){
cout<<"Possible"<<endl;
cout<<"RBR"<<endl;
cout<<"BRB"<<endl;
cout<<"RBR"<<endl;
}
continue;
}
if(n>=4){
if(k>=n*(n-1)){
k = (2*n*(n-1)) - k;
FOR(i,1,n){
FOR(j,1,n){//相加奇数是红色
if((i+j)&1) a[i][j]='R';
else a[i][j]='B';
}
}
if(k==1){
cout<<"Impossible"<<endl;
continue;
}
else{
cout<<"Possible"<<endl;
//此处我们把黑色改成红色
int cnt = k;
FOR(i,2,n){
FOR(j,1,n){
if(a[i][j]=='B'&&cnt >=3){
a[i][j]='R';
if(i==n||i==1||j==n||j==1) cnt-=3;
else cnt-=4;
}
}
}
if(cnt==1){
a[2][2]='B';
a[1][1]='R';
a[1][3]='R';
}
if(cnt==2){
a[1][1]='R';
}
if(cnt==3){
a[1][3]='R';
}
FOR(i,1,n){
FOR(j,1,n){
cout<<a[i][j];
}
cout<<endl;
}
}
}
else{
FOR(i,1,n){
FOR(j,1,n){//默认是黑色
a[i][j]='B';
}
}
if(k==1){
cout<<"Impossible"<<endl;
continue;
}
else{
cout<<"Possible"<<endl;
//此处我们把黑色改成红色
int cnt = k;
FOR(i,2,n){
FOR(j,1,n){
if(!((i+j)&1) &&cnt >=3){
a[i][j]='R';
if(i==n||i==1||j==n||j==1) cnt-=3;
else cnt-=4;
}
}
}
if(cnt==1){
a[2][2]='B';
a[1][1]='R';
a[1][3]='R';
}
if(cnt==2){
a[1][1]='R';
}
if(cnt==3){
a[1][3]='R';
}
FOR(i,1,n){
FOR(j,1,n){
cout<<a[i][j];
}
cout<<endl;
}
}
}
}
}
return 0;
}
/*
10
5 7
4 23
4 20
4 12
*/
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3464kb
input:
2 3 6 3 1
output:
Possible RBR RRB RRR Impossible
result:
ok correct! (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 45ms
memory: 3444kb
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 RB RR Impossible Possible RR RR Possible RBR BRB RBR Impossible Possible RBR BRB RBB Possible RBR BRB RRR Possible BRB RRR BRB Possible BRR RRB BRR Possible RBR RRB RRR Possible BRR RRB RRR Possible RRR RBR RRR Possible RBR RRR RRR Possible BRR RRR RRR I...
result:
wrong answer Condition failed: "getNum(vec) == k" (test case 23)