#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <iomanip>
#include <cassert>
#include <deque>
#include <functional>
#include <set>
#include <queue>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <complex>
using namespace std;
int gcd(int a, int b) {
if (!b) {
return a;
}
return gcd(b, a % b);
}
int32_t main() {
int t;
cin >> t;
while (t--) {
int n, m, k;
cin >> n >> m >> k;
if (n % 2 == 1 || m % 2 == 1) {
cout << "NO" << '\n';
} else {
bool ok = false;
for (int borderSize = 0; borderSize < min(n, m) / 2; ++borderSize) {
if (borderSize + (n - 2 * borderSize) * (m - 2 * borderSize) / 4 == k) {
vector<vector<int>> matr(n, vector<int> (m, 0));
for (int i = 0; i < borderSize; ++i) {
for (int j = i; j < m - i; ++j) {
matr[i][j] = i + 1;
matr[n - i - 1][j] = i + 1;
}
for (int j = i; j < n - i; ++j) {
matr[j][i] = i + 1;
matr[j][m - i - 1] = i + 1;
}
}
int c = borderSize;
for (int x = borderSize; x < n - borderSize; x += 2) {
for (int y = borderSize; y < m - borderSize; y += 2) {
matr[x][y] = matr[x + 1][y] = matr[x][y + 1] = matr[x + 1][y + 1] = ++c;
}
}
cout << "YES\n";
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
cout << matr[i][j] << ' ';
}
cout << '\n';
}
ok = true;
break;
}
}
if (!ok) {
cout << "NO\n";
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
716 KB |
Correct! Azusa and Laika like the garden :) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
716 KB |
Correct! Azusa and Laika like the garden :) |
2 |
Failed |
11 ms |
444 KB |
Incorrect output |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
716 KB |
Correct! Azusa and Laika like the garden :) |
2 |
Failed |
11 ms |
444 KB |
Incorrect output |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Failed |
2 ms |
340 KB |
Incorrect output |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Failed |
1 ms |
212 KB |
Incorrect output |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
716 KB |
Correct! Azusa and Laika like the garden :) |
2 |
Failed |
11 ms |
444 KB |
Incorrect output |
3 |
Halted |
0 ms |
0 KB |
- |