QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#534595#9114. Black or White 2synonymWA 165ms3740kbC++171.9kb2024-08-27 14:17:132024-08-27 14:17:13

Judging History

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

  • [2024-08-27 14:17:13]
  • 评测
  • 测评结果:WA
  • 用时:165ms
  • 内存:3740kb
  • [2024-08-27 14:17:13]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()

const int mxn=2e3;

int n,m,k,fl,nm;
int g[mxn][mxn];

void solve2() {
	if (k%2) {
		for (int i=0; i<m; i++) {
			if (k==0) break;
			g[0][i] = 1; k--; if (k==0) break;
			g[1][i] = 1; k--; if (k==0) break;
		}
	} else {
		if (k==0) return;
		g[0][m-1] = 1; k--;
		for (int i=0; i<m; i++) {
			if (k==0) break;
			g[0][i] = 1; k--; if (k==0) break;
			g[1][i] = 1; k--; if (k==0) break;
		}
	}
}

void solvek2() {
	g[0][0] = g[n-1][m-1] = 1;
}

void solven() {
	int c = 0;
	while (k >= 2*n) {
		for (int i=0; i<n; i++) {
			g[i][c] = 1; k--;
		}
		c++;
	}
	if (k >= n) {
		for (int i=0; i<n; i+=2) {
			g[i][c] = 1; k--;
		}
	}
	if (k==2) {
		g[0][m-1] = g[n-1][m-1] = 1;
	} else {
		int x = k%2;
		for (int i=0; k; i++) {
			g[i][m-1] = 1; k--;
			if (!k) break;
			if (x && i%2==0) {
				g[i][m-2] = 1; k--;
			}
			if (!x && i%2) {
				g[i][m-2] = 1; k--;
			}
		}
	}
}

void solve() {
	cin>>n>>m>>k;
	if (2*k > n*m) {
		fl = 1;
		k = n*m-k;
	} else fl = 0;
	if (n>m) {
		nm = 1;
		swap(n,m);
	} else nm = 0;
	
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) g[i][j]=0;
	}
	
	if (n==2) {
		solve2();
	} else if (k==2) {
		solvek2();
	} else {
		solven();
	}
	
	if (fl) {
		for (int i=0; i<n; i++) {
			for (int j=0; j<m; j++) {
				g[i][j] = 1-g[i][j];
			}
		}
	}
	if (nm) {
		for (int j=0; j<m; j++) {
			for (int i=0; i<n; i++) {
				cout<<g[i][j]<<"";
			}
			cout<<"\n";
		}
	} else {
		for (int i=0; i<n; i++) {
			for (int j=0; j<m; j++) {
				cout<<g[i][j]<<"";
			}
			cout<<"\n";
		}
	}
	cout<<endl;
}

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	
	int t; cin>>t;
	while (t--) {
		solve();
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
2 2 2
2 3 0

output:

11
00

000
000


result:

ok Output is valid. OK.

Test #2:

score: -100
Wrong Answer
time: 165ms
memory: 3740kb

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

001
000
000

100
000
001

101
000
100

101
000
101

010
111
010

010
111
011

011
111
110

110
111
111

111
111
111

00...

result:

wrong answer Output doesn't minimize loss.