#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 a[n][m]{};
int mx = (n / 2) * (m / 2);
if (k > mx) {
cout << "NO\n";
continue;
}
cout << "YES\n";
bool must[n][n]{};
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];
} else if (j - 1 >= 0) {
a[i][j] = a[i][j - 1];
} else if (i - 1 >= 0) {
a[i][j] = a[i - 1][j];
}
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cout << a[i][j] << ' ';
}
cout << '\n';
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Failed |
15 ms |
1116 KB |
Output contains flowers without two equal neighbours |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Failed |
15 ms |
1116 KB |
Output contains flowers without two equal neighbours |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Failed |
15 ms |
1116 KB |
Output contains flowers without two equal neighbours |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Failed |
8 ms |
604 KB |
Output contains flowers without two equal neighbours |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Failed |
3 ms |
344 KB |
Output contains flowers without two equal neighbours |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Failed |
15 ms |
1116 KB |
Output contains flowers without two equal neighbours |
2 |
Halted |
0 ms |
0 KB |
- |