QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#385799 | #4633. Coprime Matrices | _LAP_ | WA | 0ms | 3672kb | C++14 | 947b | 2024-04-11 06:47:10 | 2024-04-11 06:47:10 |
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 = get(x, y) - w;
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3672kb
input:
3 3 2 1 3
output:
Yes 9 3 4 1 2 5 6 7 8
result:
wrong answer A[x][y] not Equal w