QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#549143 | #9114. Black or White 2 | Charizard2021 | WA | 0ms | 3512kb | C++14 | 2.0kb | 2024-09-06 10:23:14 | 2024-09-06 10:23:14 |
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] << " ";
}
}
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] << " ";
}
}
cout << "\n";
}
}
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3512kb
input:
2 2 2 2 2 3 0
output:
1 0 0 1 0 0 0 0 0 0
result:
wrong answer