QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#512600#9114. Black or White 2fansizheAC ✓167ms12692kbC++201.3kb2024-08-10 15:04:002024-08-10 15:04:00

Judging History

你现在查看的是最新测评结果

  • [2024-08-10 15:04:00]
  • 评测
  • 测评结果:AC
  • 用时:167ms
  • 内存:12692kb
  • [2024-08-10 15:04:00]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int a[1505][1505];
void solve(){
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;i++)for(int j=0;j<m;j++)a[i][j]=0;
	if(n*m<=10){
		for(int sta=0;sta<1<<n*m;sta++){
			int cnt=0;
			for(int i=0;i<n*m;i++)if(sta>>i&1)cnt++;
			if(cnt==k){
				for(int i=0;i<n;i++)for(int j=0;j<m;j++)a[i][j]=(sta>>i*m+j&1);
				int flag=1;
				for(int i=1;i<n;i++)for(int j=1;j<m;j++)if(a[i][j]+a[i-1][j]+a[i][j-1]+a[i-1][j-1]==2)flag=0;
				if(flag){
					for(int i=0;i<n;i++,puts(""))for(int j=0;j<m;j++)printf("%d",a[i][j]);
					return;
				}
			}
		}
		for(int i=0;i<n;i++,puts(""))for(int j=0;j<m;j++)if(k)putchar('1'),k--;else putchar('0');
	}else if(k<=3){
		for(int i=0;i<n;i+=2)for(int j=0;j<m;j+=2)if(k)k--,a[i][j]=1;
		for(int i=0;i<n;i++,puts(""))for(int j=0;j<m;j++)printf("%d",a[i][j]);
	}else{
		for(int i=0;i<m;i+=2)if(k>0){
			a[0][i]=1,k--;
			if(i&&k>0){
				a[0][i-1]=a[1][i-1]=1;
				k-=2;
				if(k>0){
					a[1][i-2]=1,k--;
					if(n>2)a[2][i-2]=1,k--;
				}
			}
		}
		for(int i=0;i<n;i++){
			for(int j=i&1^1;j<m;j+=2)if(!a[i][j]&&k>0){
				a[i][j]=1,k--;
				if(i<n-1)a[i+1][j]=1,k--;
			}
		}
		if(k<0)a[0][0]=0;
		for(int i=0;i<n;i++,puts(""))for(int j=0;j<m;j++)printf("%d",a[i][j]);
	}
}
int main(){
	int _;scanf("%d",&_);
	while(_--)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3892kb

input:

2
2 2 2
2 3 0

output:

11
00
000
000

result:

ok Output is valid. OK.

Test #2:

score: 0
Accepted
time: 156ms
memory: 3860kb

input:

27520
2 2 0
2 2 1
2 2 2
2 2 3
2 2 4
2 3 0
2 3 1
2 3 2
2 3 3
2 3 4
2 3 5
2 3 6
3 2 0
3 2 1
3 2 2
3 2 3
3 2 4
3 2 5
3 2 6
3 3 0
3 3 1
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
3 3 8
3 3 9
2 4 0
2 4 1
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
2 4 7
2 4 8
3 4 0
3 4 1
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10...

output:

00
00
10
00
11
00
11
10
11
11
000
000
100
000
101
000
110
100
111
010
111
110
111
111
00
00
00
10
00
00
10
00
10
11
10
00
10
11
10
11
11
10
11
11
11
000
000
000
100
000
000
101
000
000
110
100
000
111
010
000
111
101
000
111
110
100
111
111
010
111
111
110
111
111
111
0000
0000
1000
0000
1010
0000
1...

result:

ok Output is valid. OK.

Test #3:

score: 0
Accepted
time: 145ms
memory: 12472kb

input:

162
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4 9
...

output:

11
00
101
000
110
100
111
010
10
00
10
11
10
00
10
11
10
101
000
000
110
100
000
111
010
000
111
101
000
111
110
100
111
111
010
1010
0000
1100
1000
1101
1000
1110
1100
1111
1010
1010
0000
0000
1010
0000
1000
1110
0100
0000
0110
1100
1000
1110
1100
1000
0111
1101
1000
1111
1101
1000
0111
1111
1010
1...

result:

ok Output is valid. OK.

Test #4:

score: 0
Accepted
time: 141ms
memory: 12172kb

input:

163
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4 9
...

output:

11
00
101
000
110
100
111
010
10
00
10
11
10
00
10
11
10
101
000
000
110
100
000
111
010
000
111
101
000
111
110
100
111
111
010
1010
0000
1100
1000
1101
1000
1110
1100
1111
1010
1010
0000
0000
1010
0000
1000
1110
0100
0000
0110
1100
1000
1110
1100
1000
0111
1101
1000
1111
1101
1000
0111
1111
1010
1...

result:

ok Output is valid. OK.

Test #5:

score: 0
Accepted
time: 147ms
memory: 12460kb

input:

165
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4 9
...

output:

11
00
101
000
110
100
111
010
10
00
10
11
10
00
10
11
10
101
000
000
110
100
000
111
010
000
111
101
000
111
110
100
111
111
010
1010
0000
1100
1000
1101
1000
1110
1100
1111
1010
1010
0000
0000
1010
0000
1000
1110
0100
0000
0110
1100
1000
1110
1100
1000
0111
1101
1000
1111
1101
1000
0111
1111
1010
1...

result:

ok Output is valid. OK.

Test #6:

score: 0
Accepted
time: 151ms
memory: 11844kb

input:

1020
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4 9...

output:

11
00
101
000
110
100
111
010
10
00
10
11
10
00
10
11
10
101
000
000
110
100
000
111
010
000
111
101
000
111
110
100
111
111
010
1010
0000
1100
1000
1101
1000
1110
1100
1111
1010
1010
0000
0000
1010
0000
1000
1110
0100
0000
0110
1100
1000
1110
1100
1000
0111
1101
1000
1111
1101
1000
0111
1111
1010
1...

result:

ok Output is valid. OK.

Test #7:

score: 0
Accepted
time: 148ms
memory: 12508kb

input:

1012
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4 9...

output:

11
00
101
000
110
100
111
010
10
00
10
11
10
00
10
11
10
101
000
000
110
100
000
111
010
000
111
101
000
111
110
100
111
111
010
1010
0000
1100
1000
1101
1000
1110
1100
1111
1010
1010
0000
0000
1010
0000
1000
1110
0100
0000
0110
1100
1000
1110
1100
1000
0111
1101
1000
1111
1101
1000
0111
1111
1010
1...

result:

ok Output is valid. OK.

Test #8:

score: 0
Accepted
time: 143ms
memory: 12376kb

input:

1033
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4 9...

output:

11
00
101
000
110
100
111
010
10
00
10
11
10
00
10
11
10
101
000
000
110
100
000
111
010
000
111
101
000
111
110
100
111
111
010
1010
0000
1100
1000
1101
1000
1110
1100
1111
1010
1010
0000
0000
1010
0000
1000
1110
0100
0000
0110
1100
1000
1110
1100
1000
0111
1101
1000
1111
1101
1000
0111
1111
1010
1...

result:

ok Output is valid. OK.

Test #9:

score: 0
Accepted
time: 167ms
memory: 3852kb

input:

100000
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4...

output:

11
00
101
000
110
100
111
010
10
00
10
11
10
00
10
11
10
101
000
000
110
100
000
111
010
000
111
101
000
111
110
100
111
111
010
1010
0000
1100
1000
1101
1000
1110
1100
1111
1010
1010
0000
0000
1010
0000
1000
1110
0100
0000
0110
1100
1000
1110
1100
1000
0111
1101
1000
1111
1101
1000
0111
1111
1010
1...

result:

ok Output is valid. OK.

Test #10:

score: 0
Accepted
time: 78ms
memory: 3980kb

input:

100000
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4...

output:

11
00
101
000
110
100
111
010
10
00
10
11
10
00
10
11
10
101
000
000
110
100
000
111
010
000
111
101
000
111
110
100
111
111
010
1010
0000
1100
1000
1101
1000
1110
1100
1111
1010
1010
0000
0000
1010
0000
1000
1110
0100
0000
0110
1100
1000
1110
1100
1000
0111
1101
1000
1111
1101
1000
0111
1111
1010
1...

result:

ok Output is valid. OK.

Test #11:

score: 0
Accepted
time: 77ms
memory: 3908kb

input:

100000
2 2 2
2 3 2
2 3 3
2 3 4
3 2 2
3 2 3
3 2 4
3 3 2
3 3 3
3 3 4
3 3 5
3 3 6
3 3 7
2 4 2
2 4 3
2 4 4
2 4 5
2 4 6
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 4 10
4 2 2
4 2 3
4 2 4
4 2 5
4 2 6
4 3 2
4 3 3
4 3 4
4 3 5
4 3 6
4 3 7
4 3 8
4 3 9
4 3 10
4 4 2
4 4 3
4 4 4
4 4 5
4 4 6
4 4 7
4 4 8
4 4...

output:

11
00
101
000
110
100
111
010
10
00
10
11
10
00
10
11
10
101
000
000
110
100
000
111
010
000
111
101
000
111
110
100
111
111
010
1010
0000
1100
1000
1101
1000
1110
1100
1111
1010
1010
0000
0000
1010
0000
1000
1110
0100
0000
0110
1100
1000
1110
1100
1000
0111
1101
1000
1111
1101
1000
0111
1111
1010
1...

result:

ok Output is valid. OK.

Test #12:

score: 0
Accepted
time: 147ms
memory: 12568kb

input:

3
1500 1500 2250000
1322 1322 1747684
1158 2 2316

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok Output is valid. OK.

Test #13:

score: 0
Accepted
time: 150ms
memory: 12692kb

input:

3
1500 1500 1125000
1322 1322 873842
1158 2 1158

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok Output is valid. OK.

Extra Test:

score: 0
Extra Test Passed