QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#503652#9114. Black or White 2ucup-team191#AC ✓172ms14868kbC++232.6kb2024-08-03 21:58:122024-08-03 21:58:12

Judging History

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

  • [2024-08-03 21:58:12]
  • 评测
  • 测评结果:AC
  • 用时:172ms
  • 内存:14868kb
  • [2024-08-03 21:58:12]
  • 提交

answer

#include <cstdio>
#include <vector>

using namespace std;

const int N = 2e3 + 50;

int A[N][N], n, m, k;

void solve(int n, int m, int k) {
//	scanf("%d%d%d", &n, &m, &k);
	int kk = k;
	int flip = 0, trans = 0;
	if(k > n * m - k) k = n * m - k, flip = 1;
	if(n > m) swap(n, m), trans = 1;
	for(int i = 0;i < n;i++)
		for(int j = 0;j < m;j++) A[i][j] = 0;
	int ima_free = 0;
	for(int i = 0;i < n;i++)	
		for(int j = 0;j < m;j++)
			if(i % 2 == 0 && j % 2 == 0) ima_free++;
	if(k <= ima_free) {
		for(int i = 0;i < n;i++) {
			for(int j = 0;j < m;j++) {
				if(i % 2 == 0 && j % 2 == 0 && k > 0) {
					A[i][j] = 1; k--;
				} else {
					A[i][j] = 0;
				}
			}
		}
	} else if (n == 2 && m == 2 && k == 2) {
		A[0][0] = 1; A[1][0] = 1;
	} else if (n == 4 && m == 4 && k == 5) {
		A[0][0] = 1; A[1][0] = 1; A[0][1] = 1;
		A[0][3] = 1; A[3][0] = 1;
	} else if (n == 4 && m == 5 && k == 9) {
		A[0][0] = 1; A[1][0] = 1; A[0][1] = 1;
		A[0][2] = 1; A[1][1] = 1; A[2][0] = 1;
		A[3][4] = 1; A[1][4] = 1; A[3][2] = 1;
	} else if (n == 5 && m == 5 && k == 12) {
		A[0][0] = 1; A[1][0] = 1; A[0][1] = 1;
		A[0][2] = 1; A[1][1] = 1; A[2][0] = 1;
		A[0][3] = 1; A[1][2] = 1; A[2][1] = 1; A[3][0] = 1;
		A[2][4] = 1; A[4][2] = 1;
	} else {
		int uzmi = 0;
		while(uzmi * n + (n + 1) / 2 <= k) uzmi++;
		uzmi--;
		for(int j = 0;j < uzmi;j++) {
			for(int i = 0;i < n;i++) A[i][j] = 1;
		}
		for(int i = 0;i < n;i += 2) A[i][uzmi] = 1;
		k -= uzmi * n + (n + 1) / 2;
		for(int j = m - 1;j >= 0;j--)
			for(int i = n - 1;i >= 0;i--)
				if(i % 2 == 0 && j % 2 == (m - 1) % 2 && k > 0) {
					A[i][j] = 1; k -= 1;
				}
	}
	for(int i = 0;i < n;i++)
		for(int j = 0;j < m;j++)
			A[i][j] ^= flip;
	int ans = 0, cnt_jen = 0;
	for(int i = 0;i < n;i++)	
		for(int j = 0;j < m;j++)
			if(A[i][j]) cnt_jen++;
	if(cnt_jen != kk) {
		printf("(%d, %d, %d) : KRIVI BROJ JEDINICA %d != %d\n", n, m, kk, cnt_jen, kk);
		return;
	}
	for(int i = 0;i + 1 < n;i++)
		for(int j = 0;j + 1 < m;j++)
			if(A[i][j] + A[i + 1][j] + A[i][j + 1] + A[i + 1][j + 1] == 2) ans++;
	//printf("ANS = %d\n", ans);
	//if(ans) printf("\n\n\t\t (%d, %d, %d) :  NIJE NULA(%d )\n\n\n", n, m, kk, ans);
	//return;
	if(!trans) {
		for(int i = 0;i < n;i++) {
			for(int j = 0;j < m;j++)
				printf("%d", A[i][j]);
			printf("\n");
		}
	} else {
		for(int j = 0;j < m;j++) {
			for(int i = 0;i < n;i++) {
				printf("%d", A[i][j]);
			}
			printf("\n");
			
		}
	}
}

int main() {
	int T; scanf("%d", &T);
	for(;T--;) {
		int n, m, k; scanf("%d%d%d", &n, &m, &k);
		solve(n, m, k);
	}
	return 0;
}

详细

Test #1:

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

input:

2
2 2 2
2 3 0

output:

10
10
000
000

result:

ok Output is valid. OK.

Test #2:

score: 0
Accepted
time: 163ms
memory: 1656kb

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

result:

ok Output is valid. OK.

Test #3:

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

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

result:

ok Output is valid. OK.

Test #4:

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

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

result:

ok Output is valid. OK.

Test #5:

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

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

result:

ok Output is valid. OK.

Test #6:

score: 0
Accepted
time: 162ms
memory: 1688kb

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

result:

ok Output is valid. OK.

Test #7:

score: 0
Accepted
time: 157ms
memory: 1724kb

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

result:

ok Output is valid. OK.

Test #8:

score: 0
Accepted
time: 157ms
memory: 1616kb

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

result:

ok Output is valid. OK.

Test #9:

score: 0
Accepted
time: 172ms
memory: 1680kb

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

result:

ok Output is valid. OK.

Test #10:

score: 0
Accepted
time: 71ms
memory: 1624kb

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

result:

ok Output is valid. OK.

Test #11:

score: 0
Accepted
time: 70ms
memory: 1648kb

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

result:

ok Output is valid. OK.

Test #12:

score: 0
Accepted
time: 149ms
memory: 14868kb

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: 152ms
memory: 14384kb

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