QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#476149#9114. Black or White 2ucup-team3510#AC ✓45ms11684kbC++202.1kb2024-07-13 17:58:392024-07-13 17:58:41

Judging History

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

  • [2024-07-13 17:58:41]
  • 评测
  • 测评结果:AC
  • 用时:45ms
  • 内存:11684kb
  • [2024-07-13 17:58:39]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int T,n,m,k,c;char s[2011][2011],t[2011][2011];bool flg;
int a[2011];
void print()
{
	if(c%2!=k%2)s[1][1]='0',--c;
	if(flg)
	{
		for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)t[j][i]=s[i][j];
		for(int i=1;i<=m;++i)t[i][n+1]=0;
		for(int i=1;i<=m;++i)printf("%s\n",t[i]+1);
	}
	else
	{
		for(int i=1;i<=n;++i)s[i][m+1]=0;
		for(int i=1;i<=n;++i)printf("%s\n",s[i]+1);
	}
}
int main()
{
	scanf("%d",&T);while(T--)
	{
		scanf("%d%d%d",&n,&m,&k);
		for(int i=1;i<=n;++i)s[i][m+1]=0;
		for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)s[i][j]='0';
		if(k==0)
		{
			for(int i=1;i<=n;++i)printf("%s\n",s[i]+1);
			continue;
		}
		if(k==1)
		{
			s[1][1]='1';
			for(int i=1;i<=n;++i)printf("%s\n",s[i]+1);
			continue;
		}
		if(k==3)
		{
			s[1][1]=s[1][2]=s[2][1]='1';
			for(int i=1;i<=n;++i)printf("%s\n",s[i]+1);
			continue;
		}
		if(n==2&m==2)
		{
			int cc=0;
			for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)
			{
				++cc;if(cc<=k)s[i][j]='1';
			}
			for(int i=1;i<=n;++i)printf("%s\n",s[i]+1);
			continue;
		}
		flg=0;
		if(m==2)
		{
			flg=1,swap(n,m);
			for(int i=1;i<=n;++i)for(int j=1;j<=m;++j)s[i][j]='0';
		}
		c=0;
		for(int i=1;i<=m;++i)a[i]=0;
		for(int i=1;i<=m;i+=2)
		{
			a[i]=1;
			s[1][i]='1';++c;
			if(c>=k)break;
			for(int j=i-1;j;--j)
			{
				if(a[j]+2<=n)
				{
					c+=2;
					s[a[j]+1][j]=s[a[j]+2][j]='1';
					a[j]+=2;
					if(c>=k)break;
				}
				else if(a[j]+1<=n)
				{
					++c;
					s[a[j]+1][j]='1';
					a[j]+=1;
					if(c>=k)break;
				}
			}
			if(c>=k)break;
		}
//		for(int i=1;i<=n;++i)printf("%s\n",s[i]+1);
//		printf("c:%d\n",c);
		if(c>=k)
		{
			print();
		}
		else
		{
			while(1)
			{
				for(int j=m;j;--j)
				{
					if(a[j]+2<=n)
					{
						c+=2;
						s[a[j]+1][j]=s[a[j]+2][j]='1';
						a[j]+=2;
						if(c>=k)break;
					}
					else if(a[j]+1<=n)
					{
						++c;
						s[a[j]+1][j]='1';
						a[j]+=1;
						if(c>=k)break;
					}
				}
				if(c>=k)break;
//				for(int i=1;i<=n;++i)printf("%s\n",s[i]+1);
//				printf("c:%d\n",c);
			}
			print();
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 18ms
memory: 5848kb

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
011
110
100
111
110
100
011
111
101
111
111
101
111
111
111
0000
0000
1000
0000
1010
0000
1...

result:

ok Output is valid. OK.

Test #3:

score: 0
Accepted
time: 0ms
memory: 11152kb

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
011
110
100
111
110
100
011
111
101
1010
0000
1100
1000
1110
0100
1110
1100
0111
1101
1010
0000
0000
1100
1000
0000
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: 0ms
memory: 7872kb

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
011
110
100
111
110
100
011
111
101
1010
0000
1100
1000
1110
0100
1110
1100
0111
1101
1010
0000
0000
1100
1000
0000
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: 3ms
memory: 10688kb

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
011
110
100
111
110
100
011
111
101
1010
0000
1100
1000
1110
0100
1110
1100
0111
1101
1010
0000
0000
1100
1000
0000
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: 30ms
memory: 11684kb

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
011
110
100
111
110
100
011
111
101
1010
0000
1100
1000
1110
0100
1110
1100
0111
1101
1010
0000
0000
1100
1000
0000
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: 30ms
memory: 10684kb

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
011
110
100
111
110
100
011
111
101
1010
0000
1100
1000
1110
0100
1110
1100
0111
1101
1010
0000
0000
1100
1000
0000
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: 27ms
memory: 10704kb

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
011
110
100
111
110
100
011
111
101
1010
0000
1100
1000
1110
0100
1110
1100
0111
1101
1010
0000
0000
1100
1000
0000
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: 45ms
memory: 5888kb

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
011
110
100
111
110
100
011
111
101
1010
0000
1100
1000
1110
0100
1110
1100
0111
1101
1010
0000
0000
1100
1000
0000
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: 42ms
memory: 5880kb

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
011
110
100
111
110
100
011
111
101
1010
0000
1100
1000
1110
0100
1110
1100
0111
1101
1010
0000
0000
1100
1000
0000
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: 38ms
memory: 5824kb

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
011
110
100
111
110
100
011
111
101
1010
0000
1100
1000
1110
0100
1110
1100
0111
1101
1010
0000
0000
1100
1000
0000
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: 0ms
memory: 10664kb

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: 3ms
memory: 10924kb

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