QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#512593#9114. Black or White 2fansizheTL 1254ms12620kbC++201.3kb2024-08-10 15:02:502024-08-10 15:02:54

Judging History

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

  • [2024-08-10 15:02:54]
  • 评测
  • 测评结果:TL
  • 用时:1254ms
  • 内存:12620kb
  • [2024-08-10 15:02:50]
  • 提交

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<=18){
		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: 3876kb

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: 184ms
memory: 3896kb

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: 148ms
memory: 12320kb

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
1100
1000
0000
1101
1000
0000
0110
1100
1000
1111
1010
0000
0111
1101
1000
1111
1101
1000
1111
1110
1100
1...

result:

ok Output is valid. OK.

Test #4:

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

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
1100
1000
0000
1101
1000
0000
0110
1100
1000
1111
1010
0000
0111
1101
1000
1111
1101
1000
1111
1110
1100
1...

result:

ok Output is valid. OK.

Test #5:

score: 0
Accepted
time: 138ms
memory: 12620kb

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
1100
1000
0000
1101
1000
0000
0110
1100
1000
1111
1010
0000
0111
1101
1000
1111
1101
1000
1111
1110
1100
1...

result:

ok Output is valid. OK.

Test #6:

score: 0
Accepted
time: 144ms
memory: 12500kb

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
1100
1000
0000
1101
1000
0000
0110
1100
1000
1111
1010
0000
0111
1101
1000
1111
1101
1000
1111
1110
1100
1...

result:

ok Output is valid. OK.

Test #7:

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

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
1100
1000
0000
1101
1000
0000
0110
1100
1000
1111
1010
0000
0111
1101
1000
1111
1101
1000
1111
1110
1100
1...

result:

ok Output is valid. OK.

Test #8:

score: 0
Accepted
time: 144ms
memory: 12584kb

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
1100
1000
0000
1101
1000
0000
0110
1100
1000
1111
1010
0000
0111
1101
1000
1111
1101
1000
1111
1110
1100
1...

result:

ok Output is valid. OK.

Test #9:

score: 0
Accepted
time: 1254ms
memory: 3808kb

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
1100
1000
0000
1101
1000
0000
0110
1100
1000
1111
1010
0000
0111
1101
1000
1111
1101
1000
1111
1110
1100
1...

result:

ok Output is valid. OK.

Test #10:

score: -100
Time Limit Exceeded

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
1100
1000
0000
1101
1000
0000
0110
1100
1000
1111
1010
0000
0111
1101
1000
1111
1101
1000
1111
1110
1100
1...

result: