QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#762752 | #5438. Half Mixed | fosov | WA | 0ms | 3552kb | C++14 | 1.6kb | 2024-11-19 16:30:44 | 2024-11-19 16:30:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lll __int128
#define INF 0x3f3f3f3f
#define LNF 0x3f3f3f3f3f3f3f3fll
#define MOD 998244353
#define pii pair<int, int>
#define pdd pair<double, double>
#define tdd tuple<double, double, double>
#define N 20
vector<int> gen(ll n) {
assert((n*(n+1)/2) % 2 == 0);
vector<int> res;
int x = 0;
ll tar = n*(n+1)/4;
for (ll i = n; i >= 1; -- i) {
ll cur = i*(i+1)/2;
while (tar >= cur && (tar - cur) >= n - res.size() - i) {
for (int j = 0; j < i; ++ j) res.emplace_back(x);
x ^= 1;
tar -= cur;
}
}
return res;
}
int main() {
#ifdef TEST
freopen("zz.in", "r+", stdin);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t; cin >> t;
while (t --) {
ll n, m; cin >> n >> m;
ll tot = n*m*(n+1)*(m+1)/4;
if (tot % 2 == 1) {
cout << "No\n"; continue;
}
vector<vector<int>> g(n, vector<int>(m));
ll x = n, y = m, f = 0;
if ((x*(x+1)/2) % 2 != 0) swap(x, y), f = 1;
cout << x << '\n';
vector<int> r = gen(x);
for (int i = 0; i < y; ++ i) {
for (int j = 0; j < x; ++ j) {
if (!f) g[j][i] = r[j];
else g[i][j] = r[j];
}
}
cout << "Yes\n";
for (int i = 0; i < n; ++ i) {
for (int j = 0; j < m; ++ j) {
cout << g[i][j] << ' ';
}
cout << '\n';
}
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3552kb
input:
2 2 3 1 1
output:
3 Yes 0 1 0 0 1 0 No
result:
wrong answer Token "3" doesn't correspond to pattern "Yes|No" (test case 1)