QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#135041 | #6644. Red Black Grid | BoulevardDust# | WA | 8ms | 3472kb | C++17 | 1.3kb | 2023-08-05 10:49:09 | 2023-08-05 10:49:26 |
Judging History
answer
#include<bits/stdc++.h>
#define N 1005
#define re
#define ll long long
using namespace std;
int n,m,K,q,T;
inline void Rd(int &res){
re char c;res=0;
while(c=getchar(),c<48);
do res=(res<<3)+(res<<1)+(c^48);
while(c=getchar(),c>47);
}
char c[N][N];
int main(){
Rd(T);
while(T--){
Rd(n);Rd(K);
int cnt2=0,cnt3=0,cnt4=0;
for(re int i=1;i<=n;i++)
for(re int j=1;j<=n;j++){
if((i+j)%2==0)c[i][j]='B';
else{
int t1=(i==1||i==n),t2=(j==1||j==n);
if(t1&&t2)cnt2++;
else if(t1||t2)cnt3++;
else cnt4++;
}
}
int need2=-1,need3=0,need4=0;
for(re int i=0;i<=cnt2;i++)
for(re int j=0;j<=cnt3;j++){
int now=K-i*2-j*3;
if(now>=0&&now%4==0&&now/4<=cnt4){
need2=i;
need3=j;
need4=now/4;
break;
}
}
if(need2==-1){
puts("Impossible");
continue;
}
puts("Possible");
for(re int i=1;i<=n;i++)
for(re int j=1;j<=n;j++){
if((i+j)%2==0)continue;
int t1=(i==1||i==n),t2=(j==1||j==n);
if(t1&&t2 && need2)need2--,c[i][j]='R';
else if((t1||t2) && need3)need3--,c[i][j]='R';
else if(need4)need4--,c[i][j]='R';
else c[i][j]='B';
}
for(re int i=1;i<=n;i++)
for(re int j=1;j<=n;j++){
putchar(c[i][j]);
if(j==n)putchar('\n');
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3412kb
input:
2 3 6 3 1
output:
Possible BRB RBB BBB Impossible
result:
ok correct! (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 8ms
memory: 3472kb
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 Impossible Possible BRB RBR BBB Impossible Impossible Possible BRB RBB BBB Impossible Impossible Possible BRB BBB BBB Impossible Impossible Possible BBB BBB BBB Possible BRBR RBRB BRBR RBRB ...
result:
wrong answer Condition failed: "A == B" (test case 9)