QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#168443 | #5438. Half Mixed | Zhou_JK# | WA | 0ms | 3456kb | C++23 | 1.8kb | 2023-09-08 15:08:39 | 2023-09-08 15:08:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
long long way(int x) {
return 1ll * x * (x + 1) / 2;
}
void solve() {
auto getv = [&](int x) {
long long w = way(x) / 2;
cout << x << " " << w << "\n";
vector<int> lens;
for (int i = x; i >= 1; i--) {
if (w >= way(i) + x) {
lens.push_back(i);
w -= way(i);
break;
}
}
// w >= n >= rem
int rem = x - (lens.empty() ? 0 : lens[0]);
while (rem < w) {
for (int j = 10; j >= 2; j--) {
int ww = way(j) - j;
if (w - ww >= rem) {
w -= ww;
lens.push_back(j);
break;
}
}
}
while (rem--) {
lens.push_back(1);
}
return lens;
};
int n, m;
cin >> n >> m;
if (way(n) % 2 == 1 && way(m) % 2 == 1) {
cout << "No\n";
return;
}
cout << "Yes\n";
if (way(n) % 2 == 0) {
auto lens = getv(n);
int p = 0, i = 0;
vector<int> col(n);
for (int x : lens) {
while (x--) col[i++] = p;
p ^= 1;
}
for(int i=0;i<n;i++)for(int j=0;j<m;j++){
cout<<col[i]<<" \n"[j+1==m];
}
} else {
auto lens = getv(m);
int p = 0, i = 0;
vector<int> col(m);
for (int x : lens) {
cout<<x<<"\n";
while (x--) col[i++] = p;
p ^= 1;
}
for(int i=0;i<n;i++)for(int j=0;j<m;j++){
cout<<col[j]<<" \n"[j+1==m];
}
}
}
int main() {
int t;
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: 3456kb
input:
2 2 3 1 1
output:
Yes 3 3 1 1 1 0 1 0 0 1 0 No
result:
wrong answer Integer parameter [name=M[i][j]] equals to 3, violates the range [0, 1] (test case 1)