QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#385800 | #4633. Coprime Matrices | _LAP_ | WA | 0ms | 3688kb | C++14 | 947b | 2024-04-11 06:49:53 | 2024-04-11 06:49:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 310;
int n, m, x, y, w, A[N][N];
inline int get(int x, int y) {
return (x - 1 >> 1 << 1) * m + (y - 1) * 2 + ((y & 1) ^ (x & 1)) + 1;
}
int main() {
ios::sync_with_stdio(false), cin.tie(0);
cin >> n >> m >> x >> y >> w;
cout << "Yes" << '\n';
if(n == 1 && m == 1) {cout << "1" << '\n'; return 0; }
int shift = w - get(x, y);
if(shift < 0) shift += n * m;
int cur = shift;
for(int i = 1; i + 1 <= n; i += 2) {
for(int j = 1; j <= m; j ++) {
if(j & 1) A[i][j] = cur ++, A[i + 1][j] = cur ++;
else A[i + 1][j] = cur ++, A[i][j] = cur ++;
}
}
if(n & 1)
for(int j = 1; j <= m; j ++)
A[n][j] = cur ++;
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= m; j ++)
cout << A[i][j] % (n * m) + 1 << " \n"[j == m];
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
input:
3 3 2 1 3
output:
Yes 2 5 6 3 4 7 8 9 1
result:
ok OK, Accepted.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
1 1 1 1 1
output:
Yes 1
result:
ok OK, Accepted.
Test #3:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
8 3 4 2 9
output:
Yes 1 4 5 2 3 6 7 10 11 8 9 12 13 16 17 14 15 18 19 22 23 20 21 24
result:
ok OK, Accepted.
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3684kb
input:
7 6 7 2 28
output:
Yes 31 34 35 38 39 42 32 33 36 37 40 41 1 4 5 8 9 12 2 3 6 7 10 11 13 16 17 20 21 24 14 15 18 19 22 23 25 26 27 28 29 30
result:
wrong answer A[x][y] not Equal w