QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#135245 | #6644. Red Black Grid | Rd_rainydays# | Compile Error | / | / | Python3 | 3.9kb | 2023-08-05 13:12:12 | 2023-08-05 13:12:13 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-08-05 13:12:13]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-05 13:12:12]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),i##_end_=(b);i<i##_end_;++i)
static const int M=1003;
int T,n,k;
int F[M*M];
vector<int>V[2][3];
int G[2*M*M];
bool Work(int p){
REP(i,0,V[p][0].size()+1)
REP(j,0,V[p][1].size()+1){
//cerr<<i<<','<<j<<','<<k-i*2-j*3<<endl;
if(((k-i*2-j*3)&3)==0 && ((k-i*2-j*3)>>2)<=V[p][2].size()){
REP(a,0,i)F[V[p][0][a]]^=1;
REP(a,0,j)F[V[p][1][a]]^=1;
REP(a,0,(k-i*2-j*3)>>2)F[V[p][2][a]]^=1;
return 1;
}
}
return 0;
}
int main(){
scanf("%d",&T);
while(T--){
scanf("%d%d",&n,&k);
REP(i,0,2)REP(j,0,3)V[i][j].clear();
if(n==1){
if(!k)printf("Possible\nR\n");
else puts("Impossible");
continue;
}
if(n==3&&k==5){
printf("Possible\nRBB\nRRB\nRBR\n");
continue;
}
if(n==3&&k==7){
printf("Possible\nBBB\nRBR\nRRR\n");
continue;
}
// if(k==1 || k==2*n*(n=1)-1){
// puts("Impossible");
// continue;
// }
REP(i,1,n+1)REP(j,1,n+1){
F[(i-1)*n+j-1]=(i^j)&1;
int t=4-((i==1)||(i==n))-((j==1)||(j==n));
V[(i^j)&1][t-2].push_back((i-1)*n+j-1);
}
bool f=1;
//cerr<<"****"<<endl;
if(Work(0))f=0;
else if(Work(1))f=0;
if(f)puts("Impossible");
else{
puts("Possible");
REP(i,1,n+1){
REP(j,1,n+1){
putchar(F[(i-1)*n+j-1]==1?'R':'B');
}
puts("");
}
}
}
return 0;
}
/*
RBB
RRB
RBR
3 1
Impossible
3 2
Possible
RRB
RBR
BRB
3 3
Possible
BBB
RBR
BRB
3 4
Possible
BRB
RRR
BRB
3 5
Possible
RBB
RRB
RBR
3 6
Possible
RRB
RRR
BRB
3 7
Possible
BBB
RBR
RRR
3 8
Possible
RRR
RRR
BRB
3 9
Possible
BBB
BBB
BRB
3 10
Possible
RRR
RRR
RRB
3 1
Impossible
3 11
Impossible
5 1
Impossible
5 2
Possible
RRBRB
RBRBR
BRBRB
RBRBR
BRBRB
5 2
Possible
RRBRB
RBRBR
BRBRB
RBRBR
BRBRB
5 3
Possible
BRRRB
RBRBR
BRBRB
RBRBR
BRBRB
5 4
Possible
BRBRB
RRRBR
BRBRB
RBRBR
BRBRB
5 5
Possible
RRRRB
RBRBR
BRBRB
RBRBR
BRBRB
5 6
Possible
BRRRB
RBRBR
RRBRB
RBRBR
BRBRB
5 7
Possible
BRRRB
RRRBR
BRBRB
RBRBR
BRBRB
5 8
Possible
BRBRB
RRRRR
BRBRB
RBRBR
BRBRB
5 9
Possible
BRRRB
RBRBR
RRBRR
RBRBR
BRBRB
5 10
Possible
BRRRB
RRRBR
RRBRB
RBRBR
BRBRB
5 11
Possible
BRRRB
RRRRR
BRBRB
RBRBR
BRBRB
5 12
Possible
BRBRB
RRRRR
BRRRB
RBRBR
BRBRB
5 13
Possible
BRRRB
RRRBR
RRBRR
RBRBR
BRBRB
5 14
Possible
BRRRB
RRRRR
RRBRB
RBRBR
BRBRB
5 15
Possible
BRRRB
RRRRR
BRRRB
RBRBR
BRBRB
5 16
Possible
BRBRB
RRRRR
BRRRB
RRRBR
BRBRB
5 17
Possible
BRRRB
RRRRR
RRBRR
RBRBR
BRBRB
1 18
Impossible
5 18
Possible
BRRRB
RRRRR
RRRRB
RBRBR
BRBRB
5 19
Possible
BRRRB
RRRRR
BRRRB
RRRBR
BRBRB
5 20
Possible
BRBRB
RRRRR
BRRRB
RRRRR
BRBRB
5 21
Possible
BRRRB
RRRRR
RRRRR
RBRBR
BRBRB
5 22
Possible
BRRRB
RRRRR
RRRRB
RRRBR
BRBRB
5 23
Possible
BRRRB
RRRRR
BRRRB
RRRRR
BRBRB
5 24
Possible
BRRRB
RRRRR
RRRRR
RBRBR
BRRRB
5 25
Possible
BRRRB
RRRRR
RRRRR
RRRBR
BRBRB
5 26
Possible
BRRRB
RRRRR
RRRRB
RRRRR
BRBRB
5 27
Possible
RRRRB
RRRRR
RRRRR
RRRBR
BRBRB
5 28
Possible
BRRRB
RRRRR
RRRRR
RRRBR
BRRRB
5 29
Possible
BRRRB
RRRRR
RRRRR
RRRRR
BRBRB
5 30
Possible
RRRRB
RRRRR
RRRRR
RRRBR
BRRRB
5 31
Possible
RRRRB
RRRRR
RRRRR
RRRRR
BRBRB
5 32
Possible
BRRRB
RRRRR
RRRRR
RRRRR
BRRRB
5 33
Possible
RRRRR
RRRRR
RRRRR
RRRRR
BRBRB
5 34
Possible
RRRRB
RRRRR
RRRRR
RRRRR
BRRRB
5 35
Possible
RRRRR
RRRRR
RRRRR
RRRRR
RRBRB
5 36
Possible
RRRRR
RRRRR
RRRRR
RRRRR
BRRRB
5 37
Possible
RRRRR
RRRRR
RRRRR
RRRRR
RRBRR
5 38
Possible
RRRRR
RRRRR
RRRRR
RRRRR
RRRRB
5 39
Impossible
5 40
Possible
RRRRR
RRRRR
RRRRR
RRRRR
RRRRR
*/
Details
File "answer.code", line 2 using namespace std; ^^^^^^^^^ SyntaxError: invalid syntax