QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#539228 | #9114. Black or White 2 | Max_FWL | WA | 0ms | 19340kb | C++14 | 1.0kb | 2024-08-31 14:19:00 | 2024-08-31 14:19:00 |
Judging History
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 <= (fl1 ? m : n); i++){
for (int j = 1; j <= (fl1 ? n : 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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 19340kb
input:
2 2 2 2 2 3 0
output:
1 0 0 1 0 0 0 0 0 0
result:
wrong answer