This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int T;
int N, M, K;
void solve() {
cin >> N >> M >> K;
if (N % 2 || M % 2) {
cout << "NO\n";
return;
}
if (N == 2) {
if (K != M / 2) {
cout << "NO\n";
return;
}
cout << "YES\n";
for (int i = 1; i <= M / 2; i++)
cout << i << " " << i << " ";
cout << "\n";
for (int i = 1; i <= M / 2; i++)
cout << i << " " << i << " ";
cout << "\n";
return;
}
if (N == 4) {
if (K<max(N,M)/2||K>N*M/4||K==N*M/4-1) {
cout << "NO\n";
return;
}
cout << "YES\n";
if (M == 2) {
cout << "1 1\n1 1\n2 2\n2 2\n";
return;
}
vector<vector<int>> a(N + 1);
for (int i = 1; i <= N; i++) {
a[i].resize(M + 1);
for (int j = 1; j <= M; j++)
a[i][j] = K;
}
int x = K - M / 2;
int tmp = 0;
for (int i = 1; i <= x; i++)
a[1][2 * i - 1] = a[1][2 * i] = a[2][2 * i - 1] = a[2][2 * i] = ++tmp;
for (int i = 1; i <= x; i++)
a[3][2 * i - 1] = a[3][2 * i] = a[4][2 * i - 1] = a[4][2 * i] = ++tmp;
for (int i = 1; i < M/2 - x; i++)
a[2][2 * i + 2 * x] = a[2][2 * i + 2 * x + 1] = a[3][2 * i + 2 * x] = a[3][2 * i + 2 * x + 1] = ++tmp;
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= M; j++)
cout << a[i][j] << " ";
cout << "\n";
}
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> T;
while (T--)
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |