QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#809271 | #9874. Matrix Construction | ucup-team4479# | WA | 2ms | 3708kb | C++23 | 1.3kb | 2024-12-11 13:45:00 | 2024-12-11 13:45:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int a[N][N];
void solve() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j)
a[i][j] = (i - 1) * m + j;
if (i & 1) {
for (int j = 1; j + 1 <= m; j += 2) {
swap(a[i][j], a[i][j + 1]);
}
} else {
for (int j = 1; j <= m / 2; ++j) {
swap(a[i][j], a[i][m - j + 1]);
}
}
}
// map <int, bool> vis;
// for (int i = 1; i < n; ++i)
// for (int j = 1; j < m; ++j) {
// int x = a[i][j] + a[i][j + 1];
// if (vis[x]) {
// cout << -1 << endl;
// return;
// }
// vis[x] = 1;
// x = a[i][j] + a[i + 1][j];
// if (vis[x]) {
// cout << -1 << endl;
// return;
// }
// }
cout << "YES" << '\n';
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j)
cout << a[i][j] << " ";
cout << '\n';
}
}
int main() {
cin.tie(nullptr) -> ios::sync_with_stdio(false);
cout.tie(0);
int T;
cin >> T;
while (T--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3704kb
input:
2 1 1 2 3
output:
YES 1 YES 2 1 3 6 5 4
result:
ok All test cases passed. (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3708kb
input:
361 4 9 11 12 16 14 3 7 17 13 1 19 12 3 15 19 11 3 8 18 13 10 8 13 9 18 14 11 7 13 6 16 12 13 1 6 11 15 18 19 5 6 17 19 2 3 17 11 16 19 6 14 5 9 7 2 5 11 15 16 3 15 7 11 16 2 19 15 5 19 2 17 13 12 3 5 19 14 6 3 18 2 16 4 6 8 10 9 17 4 5 16 17 9 16 11 6 9 16 5 3 19 18 9 13 9 12 19 6 13 17 15 13 7 12 ...
output:
YES 2 1 4 3 6 5 8 7 9 18 17 16 15 14 13 12 11 10 20 19 22 21 24 23 26 25 27 36 35 34 33 32 31 30 29 28 YES 2 1 4 3 6 5 8 7 10 9 12 11 24 23 22 21 20 19 18 17 16 15 14 13 26 25 28 27 30 29 32 31 34 33 36 35 48 47 46 45 44 43 42 41 40 39 38 37 50 49 52 51 54 53 56 55 58 57 60 59 72 71 70 69 6...
result:
wrong answer Duplicate sum found for adjacent elements at (1,3) and (2,3) (test case 1)