QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#735456#9114. Black or White 2ucup-team134#AC ✓264ms12960kbC++172.5kb2024-11-11 20:10:042024-11-11 20:10:05

Judging History

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

  • [2024-11-11 20:10:05]
  • 评测
  • 测评结果:AC
  • 用时:264ms
  • 内存:12960kb
  • [2024-11-11 20:10:04]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ld long double
#define li __int128

using namespace std;

mt19937 rng(time(NULL));

void test(int n,int m,int k){
	vector<pair<int,int>> sq;
	vector<int> s;
	for(int i=0;i<n;i++){
		sq.pb({i,0});
		s.pb(min(i+1,m));
	}
	for(int j=1;j<m;j++){
		sq.pb({n-1,j});
		s.pb(min(m-j,n));
	}
	vector<vector<int>> ans(n,vector<int>(m));
	auto fil=[&](int i,int k){
		int x=sq[i].f,y=sq[i].s;
		while(x>=0&&y<m){
			ans[x][y]=k;
			x--;
			y++;
		}
	};
	int treba=k;
	bool sw=0;
	if(treba>(n*m)/2){
		treba=n*m-k;
		sw=1;
	}
	int my=0;
	vector<bool> uzet(sz(s));
	map<int,int> dr;
	int smm=0;
	for(int i=sz(s)-1;i>0;i--){
		smm+=s[i];
		dr[smm]=i;
	}
	auto fi=[&](int i){
		for(int j=i;j<sz(s);j++){
			uzet[j]=1;
			my+=s[j];
		}
		return;
	};
	for(int i=0;my<treba;i++){
		if(dr[treba-my]!=0){
			fi(dr[treba-my]);
			assert(my==treba);
			break;
		}
		uzet[i]=1;
		my+=s[i];
	}
	int cnt=0;
	while(my!=treba){
		for(int i=0;my>treba;i++){
			if(uzet[i]&&uzet[i+1]&&uzet[i+2]){
				uzet[i]=0;
				my-=s[i];
			}
			else{
				break;
			}
		}
		for(int i=0;my<treba;i++){
			if(dr[treba-my]!=0){
				fi(dr[treba-my]);
				assert(my==treba);
				break;
			}
			if(!uzet[i]&&!uzet[i+1]&&!uzet[i+2]){
				uzet[i]=1;
				my+=s[i];
				//printf("On %i!\n",i);
			}
			else{
				break;
			}
		}
		cnt++;
		if(cnt>5){
			printf("%i %i %i\n",n,m,k);
			assert(0);
			break;
		}
	}
	if(sw){
		for(int i=0;i<sz(s);i++){
			uzet[i]=!uzet[i];
		}
	}
	for(int i=0;i<sz(s);i++){
		fil(i,uzet[i]);
	}
	int cc=0;
	int cnt2=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cc+=ans[i][j];
		}
	}
	for(int i=0;i<n-1;i++){
		for(int j=0;j<m-1;j++){
			int c=ans[i][j]+ans[i][j+1]+ans[i+1][j]+ans[i+1][j+1];
			if(c==2){
				cnt2++;
			}
		}
	}
	assert(cc==k);
	//if(cnt2!=0)
	//printf("%i %i %i: %i\n",n,m,k,cnt2);
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			printf("%i",ans[i][j]);
		}
		printf("\n");
	}
}
int main()
{
	/*for(int n=2;n<=40;n++){
		printf("%i\n",n);
		for(int m=2;m<=40;m++){
			for(int k=0;k<=n*m;k++){
				test(n,m,k);
			}
		}
	}
	return 0;*/
	ios;
	int t;
	cin >> t;
	while(t--){
		int n,m,k;
		cin >> n >> m >> k;
		test(n,m,k);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
2 2 2
2 3 0

output:

10
01
000
000

result:

ok Output is valid. OK.

Test #2:

score: 0
Accepted
time: 199ms
memory: 3888kb

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
00
01
10
01
11
10
11
11
000
000
000
001
100
001
001
011
011
110
111
110
111
111
00
00
00
00
00
01
10
00
01
00
01
11
01
11
10
11
11
10
11
11
11
000
000
000
000
000
001
100
000
001
000
001
011
100
001
011
011
110
100
111
110
100
011
111
110
111
111
110
111
111
111
0000
0000
0000
0001
1000
0001
0...

result:

ok Output is valid. OK.

Test #3:

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

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:

10
01
100
001
001
011
011
110
10
00
01
00
01
11
01
11
10
100
000
001
000
001
011
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
0001
0011
1001
0011
1110
1100
0111
1110
1000
0000
0001
0000
0001
0011
1000
0001
0011
0110
1100
1000
0001
0011
0111
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #4:

score: 0
Accepted
time: 152ms
memory: 8000kb

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:

10
01
100
001
001
011
011
110
10
00
01
00
01
11
01
11
10
100
000
001
000
001
011
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
0001
0011
1001
0011
1110
1100
0111
1110
1000
0000
0001
0000
0001
0011
1000
0001
0011
0110
1100
1000
0001
0011
0111
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #5:

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

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:

10
01
100
001
001
011
011
110
10
00
01
00
01
11
01
11
10
100
000
001
000
001
011
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
0001
0011
1001
0011
1110
1100
0111
1110
1000
0000
0001
0000
0001
0011
1000
0001
0011
0110
1100
1000
0001
0011
0111
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #6:

score: 0
Accepted
time: 209ms
memory: 4184kb

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:

10
01
100
001
001
011
011
110
10
00
01
00
01
11
01
11
10
100
000
001
000
001
011
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
0001
0011
1001
0011
1110
1100
0111
1110
1000
0000
0001
0000
0001
0011
1000
0001
0011
0110
1100
1000
0001
0011
0111
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #7:

score: 0
Accepted
time: 212ms
memory: 4164kb

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:

10
01
100
001
001
011
011
110
10
00
01
00
01
11
01
11
10
100
000
001
000
001
011
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
0001
0011
1001
0011
1110
1100
0111
1110
1000
0000
0001
0000
0001
0011
1000
0001
0011
0110
1100
1000
0001
0011
0111
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #8:

score: 0
Accepted
time: 219ms
memory: 4232kb

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:

10
01
100
001
001
011
011
110
10
00
01
00
01
11
01
11
10
100
000
001
000
001
011
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
0001
0011
1001
0011
1110
1100
0111
1110
1000
0000
0001
0000
0001
0011
1000
0001
0011
0110
1100
1000
0001
0011
0111
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #9:

score: 0
Accepted
time: 264ms
memory: 3896kb

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:

10
01
100
001
001
011
011
110
10
00
01
00
01
11
01
11
10
100
000
001
000
001
011
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
0001
0011
1001
0011
1110
1100
0111
1110
1000
0000
0001
0000
0001
0011
1000
0001
0011
0110
1100
1000
0001
0011
0111
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #10:

score: 0
Accepted
time: 133ms
memory: 3780kb

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:

10
01
100
001
001
011
011
110
10
00
01
00
01
11
01
11
10
100
000
001
000
001
011
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
0001
0011
1001
0011
1110
1100
0111
1110
1000
0000
0001
0000
0001
0011
1000
0001
0011
0110
1100
1000
0001
0011
0111
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #11:

score: 0
Accepted
time: 125ms
memory: 3928kb

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:

10
01
100
001
001
011
011
110
10
00
01
00
01
11
01
11
10
100
000
001
000
001
011
100
001
011
011
110
100
111
110
100
011
111
110
1000
0001
0001
0011
1001
0011
1110
1100
0111
1110
1000
0000
0001
0000
0001
0011
1000
0001
0011
0110
1100
1000
0001
0011
0111
1001
0011
0111
0111
1110
1100
1111
1110
1100
0...

result:

ok Output is valid. OK.

Test #12:

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

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: 151ms
memory: 12960kb

input:

3
1500 1500 1125000
1322 1322 873842
1158 2 1158

output:

111110000000000000000000000000000000000111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok Output is valid. OK.

Extra Test:

score: 0
Extra Test Passed