Submission #644385

#TimeUsernameProblemLanguageResultExecution timeMemory
644385KarabasanGardening (RMI21_gardening)C++17
11 / 100
17 ms896 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...