QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#135068#6644. Red Black GridBoulevardDust#WA 8ms3636kbC++172.6kb2023-08-05 11:05:422023-08-05 11:05:44

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 11:05:44]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3636kb
  • [2023-08-05 11:05:42]
  • 提交

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);
		if(n==3&&K==5){
			puts("Possible");
			puts("RBB");
			puts("BBB");
			puts("BRB");
			continue;
		}
		if(n==3&&K==7){
			puts("Possible");
			puts("RBR");
			puts("BBB");
			puts("BRB");
			continue;
		}
		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("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');
				}
			continue;
		}
		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==1)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++;
				}
			}
		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("Possible");
			for(re int i=1;i<=n;i++)
				for(re int j=1;j<=n;j++){
					if((i+j)%2==1)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');
				}
			continue;
		}
		 
		 
		 
		 
		 
		if(need2==-1){
			puts("Impossible");
			continue;
		}
		
		
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3456kb

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: 3636kb

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
Possible
RBR
BRB
RBB
Possible
BRB
RBR
BBB
Possible
RBR
BBB
RBR
Possible
RBR
BBB
BRB
Possible
BRB
RBB
BBB
Possible
RBB
BBB
BRB
Possible
RBR
BBB
BBB
Possible
BRB
BBB
BBB
Possible
RBB
BBB
BBB
I...

result:

wrong answer Condition failed: "getNum(vec) == k" (test case 22)