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>
#pragma GCC target("popcnt")
using namespace std;
int main(){
cin.tie(0);ios::sync_with_stdio(0);
//1.
int n, m, k, t;
//2.
cin >> t;
//3.
for(int ii = 0; ii < t; ii++){
cin >> n >> m >> k;
if(k > (m / 2) * (n / 2)){
cout << "NO" << endl;
continue;
}
cout << "YES" << endl;
int v[n][m];
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++) v[i][j] = -1;
}
int x = 0, y = 0;
for(int i = 1; i <= k - 1; i++){
//cout << "i = " << i << " x = " << x << " y = " << y << endl;
int x1 = x, y1 = y + 2;
v[x][y] = i;
v[x][y + 1] = i;
if(y + 1 == m - 2){
v[x][y + 2] = i;
y1++;
}
v[x + 1][y] = i;
v[x + 1][y + 1] = i;
if(y + 1 == m - 2) v[x + 1][y + 2] = i;
if(x + 2 == n - 1){
x1++;
v[x + 2][y] = i;
v[x + 2][y + 1] = i;
if(y + 1 == m - 2) v[x + 2][y + 2] = i;
}
x = x1, y = y1;
if(x == n) break;
if(y == m){
x += 2;
y = 0;
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(v[i][j] == -1) v[i][j] = k;
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++) cout << v[i][j] << " ";
cout << endl;
}
}
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... |