QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#549144 | #9114. Black or White 2 | Charizard2021 | WA | 0ms | 3604kb | C++14 | 2.1kb | 2024-09-06 10:24:03 | 2024-09-06 10:24:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int n, m, k;
cin >> n >> m >> k;
bool transpose = false;
if(n < m){
swap(n, m);
transpose = true;
}
int val = (n * m)/2;
bool transpose2 = false;
if(val < k){
k = n * m - k;
transpose2 = true;
}
vector<vector<int> > a(1 + n, vector<int>(1 + m));
int idx = 1;
for(int i = 1; i <= m; i += 2){
if(k > 0){
a[1][i] = 1;
k--;
}
}
for(int i = 2; i <= n; i++){
if(k >= m){
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;
idx = i;
}
}
for (int i = 2; i <= m; i += 2){
if(k >= 2){
a[idx][i] = 1;
a[idx + 1][i] = 1;
k -= 2;
}
}
a[n][m] = k;
if(transpose){
for(int i = 1; i <= m; i++){
for(int j = 1; j <= n; j++){
if(transpose2){
cout << 1 - a[j][i];
}
else{
cout << a[j][i];
}
if(j != m){
cout << " ";
}
}
cout << "\n";
}
}
else{
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(transpose2){
cout << 1 - a[i][j];
}
else{
cout << a[i][j];
}
if(j != m){
cout << " ";
}
}
cout << "\n";
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3604kb
input:
2 2 2 2 2 3 0
output:
1 0 0 1 0 00 0 00
result:
wrong answer