// 01001100 01001111 01010100 01000001 \\
// \\
// ╦ ╔═╗╔╦╗╔═╗ \\
// ║ ║ ║ ║ ╠═╣ \\
// ╩═╝╚═╝ ╩ ╩ ╩ \\
// \\
// 01001100 01001111 01010100 01000001 \\
#include <bits/stdc++.h>
using namespace std;
#define N 500
#define nl '\n'
#define ff first
#define ss second
#define add insert
#define ll long long
#define ld long double
#define terminator main
#define pll pair<ll,ll>
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int a[N][N];
void solve(){
int x, y, z;
ll n, m, k, mx;
cin >> n >> m >> k;
mx = (n / 2) * (n / 2);
if(n != m){
cout << "YES\n1 1 1 1 1 1\n1 2 2 3 3 1\n1 2 2 3 3 1\n1 1 1 1 1 1\n";
return;
}
if(n % 2 || (n / 2 + k) % 2 || k > mx || k < n / 2){
cout << "NO\n";
return;
}
cout << "YES\n";
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
a[i][j] = 0;
x = y = z = 1;
for(int t = n; t > 2; t -= 2){
if(mx - t + 2 >= k){
mx -= t - 2;
for(int i = z; i < z + t; i++)
a[i][z] = a[z][i] = a[z + t - 1][i] = a[i][z + t - 1] = z;
z++;
}
}
for(int i = 1; i < n; i++)
for(int j = 1; j < m; j++)
if(!a[i][j] && !a[i + 1][j] && !a[i][j + 1] && !a[i + 1][j + 1])
a[i][j] = a[i + 1][j] = a[i][j + 1] = a[i + 1][j + 1] = z, z++;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++)
cout << a[i][j] << ' ';
cout << nl;
}
}
int terminator(){
L0TA;
int T;
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... |