QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#769965 | #5438. Half Mixed | False0099 | WA | 0ms | 3640kb | C++20 | 1.5kb | 2024-11-21 20:06:34 | 2024-11-21 20:06:35 |
Judging History
answer
#include <iostream>
#include <vector>
using namespace std;
void solve(int T) {
for (int _ = 0; _ < T; ++_) {
int n, m;
cin >> n >> m;
bool possible = true;
if (n == 1 && m == 1) {
cout << "No" << endl;
continue;
}
if (n == 1) {
if (m == 3) {
cout << "Yes" << endl;
cout << "0 1 0" << endl;
} else {
cout << "No" << endl;
}
continue;
}
if (m == 1) {
if (n == 3) {
cout << "Yes" << endl;
cout << "0" << endl << "1" << endl << "0" << endl;
} else {
cout << "No" << endl;
}
continue;
}
// For n >=2 and m >=2, construct a matrix with alternating rows starting with 0 and 1
cout << "Yes" << endl;
for (int i = 0; i < n; ++i) {
if (i % 2 == 0) {
for (int j = 0; j < m; ++j) {
cout << (j % 2 == 0 ? "0" : "1");
if (j < m - 1) cout << " ";
}
} else {
for (int j = 0; j < m; ++j) {
cout << (j % 2 == 0 ? "1" : "0");
if (j < m - 1) cout << " ";
}
}
cout << endl;
}
}
}
int main() {
int T;
cin >> T;
solve(T);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3640kb
input:
2 2 3 1 1
output:
Yes 0 1 0 1 0 1 No
result:
wrong answer 12 Mixed Submatrices Found, but 9 Expected (test case 1)