#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, m, k;
cin >> n >> m >> k;
int mx = (n / 2) * (m / 2);
if (k > mx) {
cout << "NO\n";
continue;
}
bool swapped = 0;
if (m < n) swap(n, m), swapped = 1;
cout << "YES\n";
int a[n][m]{};
bool must[n][m]{};
for (int i = 0; i < n && k; i += 2) {
for (int j = 0; j < m && k; j += 2) {
a[i][j] = k--;
must[i][j] = 1;
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (a[i][j]) continue;
if (i - 1 >= 0 && must[i - 1][j]) {
a[i][j] = a[i - 1][j];
must[i][j] = 1;
} else if (j - 1 >= 0) {
a[i][j] = a[i][j - 1];
} else if (i - 1 >= 0) {
a[i][j] = a[i - 1][j];
}
}
}
if (swapped) {
for (int j = 0; j < m; j++) {
for (int i = 0; i < n; i++) {
cout << a[i][j] << ' ';
}
cout << '\n';
}
} else {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << a[i][j] << ' ';
}
cout << '\n';
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
15 ms |
860 KB |
Output contains flowers without two equal neighbours |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
15 ms |
860 KB |
Output contains flowers without two equal neighbours |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
15 ms |
860 KB |
Output contains flowers without two equal neighbours |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
7 ms |
604 KB |
Output contains flowers without two equal neighbours |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
3 ms |
348 KB |
Output contains flowers without two equal neighbours |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
15 ms |
860 KB |
Output contains flowers without two equal neighbours |
2 |
Halted |
0 ms |
0 KB |
- |