QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#291380 | #4633. Coprime Matrices | yyz | WA | 0ms | 3524kb | C++14 | 2.3kb | 2023-12-26 14:21:01 | 2023-12-26 14:21:01 |
Judging History
answer
#include <bits/stdc++.h>
#define V vector
#define Vi vector<int>
#define sz(a) ((int)a.size())
#define fi first
#define se second
#define Int pair<int, int>
#define Inf ((int)1e9)
#define pb push_back
#define ins insert
#define For(i, x, y) for (int i = (x); i <= (y); i++)
#define Rep(i, x, y) for (int i = (x); i >= (y); i--)
#define seg int p, int l, int r
#define lid p << 1, l, mid
#define all(a) a.begin(), a.end()
#define rid p << 1 | 1, mid + 1, r
#define mid ((l + r) / 2)
#define Ceil(x, y) (((x) + (y)-1) / (y))
#define cmax(a, b) a = max(a, b)
#define cmin(a, b) a = min(a, b)
#define IO(x) freopen(#x ".in", "r", stdin), freopen(#x ".out", "w", stdout);
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
IO(1);
#endif
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n, m, x, y, z;
cin >> n >> m >> x >> y >> z;
V<Vi> res(n + 5, Vi(m + 5));
res[x][y] = z;
V<Vi> s(2);
For(i, 1, n * m) if (i != z) s[i & 1].pb(i);
int s0 = (n * n + 1) / 2, s1 = n * n - s0;
if (s0 == s1 || ((x + y) & 1) != (z & 1)) {
int t = ((x + y) & 1), Z = (z & 1);
Vi p(2);
p[t] = Z, p[t ^ 1] = Z ^ 1;
For(i, 1, n) For(j, 1, m) if (!res[i][j]) {
res[i][j] = s[p[(i + j) & 1]].back();
s[p[(i + j) & 1]].pop_back();
}
cout << "Yes\n";
For(i, 1, n) {
For(j, 1, m) cout << res[i][j] << ' ';
cout << '\n';
}
return 0;
}
if (z != 1) {
if (x == 1 && y == 1) {
if (n > 1)
res[n][1] = 1;
else
res[1][m] = 1;
} else
res[1][1] = 1;
For(i, 1, n) For(j, 1, m) if (!res[i][j]) {
res[i][j] = s[(i + j) & 1].back();
s[(i + j) & 1].pop_back();
}
cout << "Yes\n";
For(i, 1, n) {
For(j, 1, m) cout << res[i][j] << ' ';
cout << '\n';
}
return 0;
}
if (!res[1][1]) {
res[1][1] = s[1].back();
s[1].pop_back();
}
if (!res[1][2]) {
res[1][2] = s[1].back();
s[1].pop_back();
}
if (!res[2][1]) {
res[2][1] = s[1].back();
s[1].pop_back();
}
For(i, 1, n) For(j, 1, m) if (!res[i][j]) {
res[i][j] = s[(i + j) & 1].back();
s[(i + j) & 1].pop_back();
}
cout << "Yes\n";
For(i, 1, n) {
For(j, 1, m) cout << res[i][j] << ' ';
cout << '\n';
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3524kb
input:
3 3 2 1 3
output:
Yes 1 9 8 3 6 7 4 5 2
result:
wrong output format Expected EOLN