QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#533976 | #5438. Half Mixed | Sunlight9 | WA | 2ms | 11672kb | C++20 | 2.1kb | 2024-08-26 18:03:21 | 2024-08-26 18:03:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll num[1000003];
void solve() {
ll n, m;
cin >> n >> m;
ll tot = n * (n + 1LL) / 2LL;
int fl = 0;
if (tot % 2) fl = 1;
tot *= m * (m + 1LL) / 2LL;
if (tot & 1) {
cout << "No\n";
return;
}
ll k = n;
if (fl) k = m;
// cerr << k << '\n';
ll tar = k * (k + 1LL) / 4LL;
// cerr << tar << '\n';
vector<int> a;
while (true) {
if (!tar) break;
auto t = upper_bound(num + 1, num + 1 + 1000000, tar) - num - 1;
while (true) {
ll lst1 = tar - (ll)t * ((ll)t + 1LL) / 2LL;
ll lst2 = k - t;
if (lst1 >= lst2) {
a.emplace_back(t);
tar = lst1;
k = lst2;
break;
}
t--;
}
}
// for (int i = 0; i < ssize(a); ++i) {
// cerr << a[i] << " \n"[i == ssize(a) - 1];
// }
cout << "Yes\n";
int row = m;
k = n;
if (fl) row = n, k = m;
vector ans(row + 1, vector(k + 1, 0));
for (int i = 1; i <= row; ++i) {
int out = 1;
for (auto cnt : a) {
for (int j = 1; j <= cnt; ++j) {
ans[i][j] = out;
}
out ^= 1;
}
}
if (!fl) {
for (int i = 1; i <= k; ++i) {
for (int j = 1; j <= row; ++j) {
cout << ans[j][i] << ' ';
}
cout << '\n';
}
} else {
for (int i = 1; i <= row; ++i) {
for (int j = 1; j <= k; ++j) {
cout << ans[i][j] << ' ';
}
cout << '\n';
}
}
}
int main() {
cin.tie(nullptr) -> sync_with_stdio(false);
for (int i = 1; i <= 1000000; ++i) {
num[i] = num[i - 1] + (ll)i;
}
// for (int i = 1; i <= 10; ++i) {
// cerr << num[i] << " \n"[i == 10];
// }
int _;
cin >> _;
while (_--) solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 11672kb
input:
2 2 3 1 1
output:
Yes 1 0 0 1 0 0 No
result:
wrong answer 6 Mixed Submatrices Found, but 9 Expected (test case 1)