QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#539222#9114. Black or White 2Max_FWLWA 0ms19484kbC++141.0kb2024-08-31 14:18:132024-08-31 14:18:13

Judging History

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

  • [2024-08-31 14:18:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:19484kb
  • [2024-08-31 14:18:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N = 2010;
int T, n, m, k, fl1 = 0, fl2 = 0, a[N][N];
int row;

void Solve(){
	memset(a, 0, sizeof(a));
	
	cin >> n >> m >> k;
	
	fl1 = fl2 = 0;
	if (n < m){
		swap(n, m);
		fl1 = 1;
	}
	if (k > ((n * m) >> 1)){
		k = n * m - k;
		fl2 = 1;
	}
	
	for (int i = 1; i <= m; i += 2){
		if (!k)
			break;
		
		a[1][i] = 1;
		k--;
	}
	
	for (int i = 2; i <= n; i++){
		if (k < m)
			break;
		
		for (int j = 1; j <= m; j += 2)
			a[i][j] = 1;
		
		for (int j = 2; j <= m; j += 2)
			a[i - 1][j] = 1;
		
		k -= m;
		row = i;
	}
	
	for (int i = 2; i <= m; i += 2){
		if (k < 2)
			break;
		
		a[row][i] = 1;
		a[row + 1][i] = 1;
	}
	
	a[n][m] = k;
	
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++)
			cout << ((fl1 ? a[j][i] : a[i][j]) ^ fl2) << " " ;
		cout << endl;
	}
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> T;
	
	while (T--)
		Solve();
	
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 19484kb

input:

2
2 2 2
2 3 0

output:

1 0 
0 1 
0 0 
0 0 
0 0 

result:

wrong answer