QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#475163#9114. Black or White 2ucup-team052#AC ✓160ms19164kbC++232.5kb2024-07-13 12:03:492024-07-13 12:03:49

Judging History

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

  • [2024-07-13 12:03:49]
  • 评测
  • 测评结果:AC
  • 用时:160ms
  • 内存:19164kb
  • [2024-07-13 12:03:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline int Rnd(int l,int r) {return rnd()%(r-l+1)+l;}
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
void print(vector<int> x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);}
#define N 1505
int ans[N][N],tmp[N][N],n,m,k,op,op2;
void work()
{
	n=read(),m=read(),k=read();
	// n=Rnd(2,6),m=Rnd(2,6),k=n*m/2-Rnd(0,2);
	// printf("%d %d %d\n",n,m,k);
	op=op2=0;
	int kk=k;
	if(k>n*m/2) op=1,k=n*m-k;
	if(n==2&&m==2)
	{
		for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) ans[i][j]=0;
		for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(k) ans[i][j]=1,k--;
	}
	else
	{
		if(m<n) swap(n,m),op2=1;
		for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) ans[i][j]=0;
		if(n==5&&m==5&&k==12)
		{
			for(int i=1;i<=n;i++) for(int j=1;j<=2;j++) ans[i][j]=1;
			ans[2][3]=ans[4][3]=1;
		}
		else if(n==4&&m==5&&k==9)
		{
			for(int j=1;j<=m;j++) ans[1][j]=1;
			ans[2][1]=ans[2][3]=ans[2][5]=ans[4][1]=1;
		}
		else if(n==4&&m==4&&k==5)
		{
			ans[1][1]=ans[1][2]=ans[2][1]=ans[4][2]=ans[4][4]=1;
		}
		else
		{
			int rst=(n+1)/2;
			if(k<=rst)
			{
				for(int i=1;i<=n;i+=2) if(k) ans[i][1]=1,k--;
			}
			else
			{
				int wl=(k-rst)/n;
				for(int j=1;j<=wl;j++) for(int i=1;i<=n;i++) ans[i][j]=1,k--;
				for(int i=1;i<=n;i+=2) ans[i][wl+1]=1,k--;
				
				for(int i=1;i<=n;i+=2) if(k) ans[i][m]=1,k--;
				for(int i=1;i<=n;i+=2) if(k) ans[i][m-2]=1,k--;
			}
		}
		if(op2)
		{
			for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) tmp[i][j]=ans[i][j];
			for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) ans[j][i]=tmp[i][j];
			swap(n,m);
		}
	}
	if(op)
	{
		for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) ans[i][j]^=1;
	}
	int sum=0;
	for(int i=1;i<n;i++) for(int j=1;j<m;j++)
	{
		int w=ans[i][j]+ans[i][j+1]+ans[i+1][j]+ans[i+1][j+1];
		sum+=w==2;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++) printf("%d",ans[i][j]);
		printf("\n");
	}
	// if(n==2&&m==2&&kk==2)
	// {
		// printf("%d\n",sum);
		// if(sum!=1) exit(0);
	// }
	// else
	// {
		// printf("%d\n",sum);
		// if(sum!=0) exit(0);
	// }
}
signed main()
{
	int T=read(); while(T--) work();
	return 0;
}



详细

Test #1:

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

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: 153ms
memory: 5880kb

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
01
11
11
11
000
000
100
000
101
000
110
100
010
111
011
111
111
111
00
00
00
10
00
00
10
00
10
11
10
00
01
11
01
01
11
11
11
11
11
000
000
000
100
000
000
100
000
100
101
000
100
101
000
101
010
111
010
010
111
011
011
111
011
011
111
111
111
111
111
0000
0000
1000
0000
1001
0000
1...

result:

ok Output is valid. OK.

Test #3:

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

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
010
111
10
00
10
11
10
00
01
11
01
100
000
100
101
000
100
101
000
101
010
111
010
010
111
011
011
111
011
1001
0000
1100
1000
1101
1000
0011
0111
0110
1111
1000
0000
1000
1001
0000
1000
1001
0000
1001
1100
1000
1100
1101
1000
1100
0011
0111
0011
0110
1111
0110
0110
1111
0111
0...

result:

ok Output is valid. OK.

Test #4:

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

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
010
111
10
00
10
11
10
00
01
11
01
100
000
100
101
000
100
101
000
101
010
111
010
010
111
011
011
111
011
1001
0000
1100
1000
1101
1000
0011
0111
0110
1111
1000
0000
1000
1001
0000
1000
1001
0000
1001
1100
1000
1100
1101
1000
1100
0011
0111
0011
0110
1111
0110
0110
1111
0111
0...

result:

ok Output is valid. OK.

Test #5:

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

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
010
111
10
00
10
11
10
00
01
11
01
100
000
100
101
000
100
101
000
101
010
111
010
010
111
011
011
111
011
1001
0000
1100
1000
1101
1000
0011
0111
0110
1111
1000
0000
1000
1001
0000
1000
1001
0000
1001
1100
1000
1100
1101
1000
1100
0011
0111
0011
0110
1111
0110
0110
1111
0111
0...

result:

ok Output is valid. OK.

Test #6:

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

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
010
111
10
00
10
11
10
00
01
11
01
100
000
100
101
000
100
101
000
101
010
111
010
010
111
011
011
111
011
1001
0000
1100
1000
1101
1000
0011
0111
0110
1111
1000
0000
1000
1001
0000
1000
1001
0000
1001
1100
1000
1100
1101
1000
1100
0011
0111
0011
0110
1111
0110
0110
1111
0111
0...

result:

ok Output is valid. OK.

Test #7:

score: 0
Accepted
time: 153ms
memory: 12896kb

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
010
111
10
00
10
11
10
00
01
11
01
100
000
100
101
000
100
101
000
101
010
111
010
010
111
011
011
111
011
1001
0000
1100
1000
1101
1000
0011
0111
0110
1111
1000
0000
1000
1001
0000
1000
1001
0000
1001
1100
1000
1100
1101
1000
1100
0011
0111
0011
0110
1111
0110
0110
1111
0111
0...

result:

ok Output is valid. OK.

Test #8:

score: 0
Accepted
time: 154ms
memory: 14308kb

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
010
111
10
00
10
11
10
00
01
11
01
100
000
100
101
000
100
101
000
101
010
111
010
010
111
011
011
111
011
1001
0000
1100
1000
1101
1000
0011
0111
0110
1111
1000
0000
1000
1001
0000
1000
1001
0000
1001
1100
1000
1100
1101
1000
1100
0011
0111
0011
0110
1111
0110
0110
1111
0111
0...

result:

ok Output is valid. OK.

Test #9:

score: 0
Accepted
time: 160ms
memory: 5976kb

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
010
111
10
00
10
11
10
00
01
11
01
100
000
100
101
000
100
101
000
101
010
111
010
010
111
011
011
111
011
1001
0000
1100
1000
1101
1000
0011
0111
0110
1111
1000
0000
1000
1001
0000
1000
1001
0000
1001
1100
1000
1100
1101
1000
1100
0011
0111
0011
0110
1111
0110
0110
1111
0111
0...

result:

ok Output is valid. OK.

Test #10:

score: 0
Accepted
time: 62ms
memory: 5832kb

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
010
111
10
00
10
11
10
00
01
11
01
100
000
100
101
000
100
101
000
101
010
111
010
010
111
011
011
111
011
1001
0000
1100
1000
1101
1000
0011
0111
0110
1111
1000
0000
1000
1001
0000
1000
1001
0000
1001
1100
1000
1100
1101
1000
1100
0011
0111
0011
0110
1111
0110
0110
1111
0111
0...

result:

ok Output is valid. OK.

Test #11:

score: 0
Accepted
time: 62ms
memory: 5968kb

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
010
111
10
00
10
11
10
00
01
11
01
100
000
100
101
000
100
101
000
101
010
111
010
010
111
011
011
111
011
1001
0000
1100
1000
1101
1000
0011
0111
0110
1111
1000
0000
1000
1001
0000
1000
1001
0000
1001
1100
1000
1100
1101
1000
1100
0011
0111
0011
0110
1111
0110
0110
1111
0111
0...

result:

ok Output is valid. OK.

Test #12:

score: 0
Accepted
time: 140ms
memory: 12980kb

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: 143ms
memory: 14016kb

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