#include <bits/stdc++.h>
#define ll long long
#define fast1 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define int long long
#define mod 1000000007
#define pii pair<int,int>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse2,sse3,avx")
#pragma GCC optimize("unroll-loops")
int n,m,k;
int dizi[5][50005];
void solve()
{
cin>>n>>m>>k;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
dizi[i][j]=0;
if(n%2!=0||m%2==1)
{
cout<<"NO"<<endl;
return;
}
if(k>n*m/4)
{
cout<<"NO"<<endl;
return;
}
if(k==(n*m)/4)
{
int cnt=1;
for(int i=0;i<n;i+=2)
{
for(int j=0;j<m;j+=2)
{
dizi[i][j]=cnt;
dizi[i+1][j]=cnt;
dizi[i+1][j+1]=cnt;
dizi[i][j+1]=cnt;
cnt++;
}
}
}
else if(n==2||m==2)
{
cout<<"NO"<<endl;
return;
}
else if(k==(n*m)/4-1||k<m/2)
{
cout<<"NO"<<endl;
return;
}
else
{
int cnt=1;
int bak=0;
for(int i=0;i<n;i+=2)
for(int j=0;j<k-(m/2);j++)
{
bak=j*2;
dizi[i][bak]=cnt;
dizi[i+1][bak]=cnt;
dizi[i+1][bak+1]=cnt;
dizi[i][bak+1]=cnt;
cnt++;
}
for(int j=(k-(m/2))*2+1;j<m-1;j+=2)
for(int i=1;i<n-1;i+=2)
{
dizi[i][j]=cnt;
dizi[i+1][j]=cnt;
dizi[i+1][j+1]=cnt;
dizi[i][j+1]=cnt;
cnt++;
}
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
if(dizi[i][j]==0)
dizi[i][j]=cnt;
}
cout<<"YES"<<endl;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
cout<<dizi[i][j]<<" ";
cout<<endl;
}
}
signed main()
{
fast1
int t;
cin>>t;
while(t--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
896 KB |
Correct! Azusa and Laika like the garden :) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
896 KB |
Correct! Azusa and Laika like the garden :) |
2 |
Correct |
9 ms |
660 KB |
Correct! Azusa and Laika like the garden :) |
3 |
Correct |
10 ms |
596 KB |
Correct! Azusa and Laika like the garden :) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
896 KB |
Correct! Azusa and Laika like the garden :) |
2 |
Correct |
9 ms |
660 KB |
Correct! Azusa and Laika like the garden :) |
3 |
Correct |
10 ms |
596 KB |
Correct! Azusa and Laika like the garden :) |
4 |
Runtime error |
7 ms |
724 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
456 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
464 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
896 KB |
Correct! Azusa and Laika like the garden :) |
2 |
Correct |
9 ms |
660 KB |
Correct! Azusa and Laika like the garden :) |
3 |
Correct |
10 ms |
596 KB |
Correct! Azusa and Laika like the garden :) |
4 |
Runtime error |
7 ms |
724 KB |
Execution killed with signal 11 |
5 |
Halted |
0 ms |
0 KB |
- |