Submission #871844

#TimeUsernameProblemLanguageResultExecution timeMemory
871844Mr_PhGardening (RMI21_gardening)C++14
0 / 100
14 ms856 KiB
#include<bits/stdc++.h> #pragma GCC optimize ("Ofast") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> typedef long long ll; typedef long long int lli; typedef unsigned long long ull; using namespace std; using namespace __gnu_pbds; template<class x> using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>; ll mod=(ll)1e9+7; ll mod1=998244353; ///the defines :) #define endl '\n' #define vi vector<int> #define vll vector<ll> #define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i]; #define all(arr) arr.begin(),arr.end() #define allr(arr) arr.rbegin(),arr.rend() #define sz size() #define int long long void preprocess() {} void solve() { int n,m,k; cin>>n>>m>>k; bool lmao=false; if(n>m) { swap(n,m); lmao=true; } if((n*m)/4<k||n%2||m%2) cout<<"NO"<<endl; else if(n==2) { if(k!=(m/2)) cout<<"NO"<<endl; else { cout<<"YES"<<endl; if(!lmao) { for(int i=0; i<2; i++) { int x=1; for(int j=0; j<m; j+=2) { cout<<x<<" "<<x<<" "; x++; } cout<<endl; } } else { int x=1; for(int i=0; i<m; i+=2) { cout<<x<<" "<<x<<endl; cout<<x<<" "<<x<<endl; x++; } } } } else { int nn=n-2,mm=m-2; if((k)==((nn*mm/4)+1)) { cout<<"YES"<<endl; int ans[n][m]; int x=2; for(int i=1; i<m-1; i+=2) { ans[1][i]=x; ans[2][i+1]=x; ans[1][i+1]=x; ans[2][i]=x; x++; } for(int i=0; i<n; i++) { for(int j=0; j<m; j++) { if(i==0||j==0||i==n-1||j==m-1) cout<<1<<" "; else cout<<ans[i][j]<<" "; } cout<<endl; } } else { int cnt=0; cnt=2; int ans[n][m]; int am=-1; int curn=n-2,curm=m; for(int i=0;i<m;i+=2) { curm-=2; ans[0][i]=cnt; ans[0][i+1]=cnt; ans[1][i]=cnt; ans[1][i+1]=cnt; cnt++; ans[2][i]=cnt; ans[2][i+1]=cnt; ans[3][i]=cnt; ans[3][i+1]=cnt; cnt++; k-=2; if((k)==((curn*(curm-2)/4)+1)) { am=i+2; break; } } if(am==-1) { cout<<"NO"<<endl; return; } cout<<"YES"<<endl; for(int i=am+1;i<m-1;i+=2) { ans[1][i]=cnt; ans[2][i+1]=cnt; ans[1][i+1]=cnt; ans[2][i]=cnt; cnt++; } for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { if((i==0&&j>=am)||(j==am)||(i==3&&j>=am)||(j==m-1&&j>=am)) cout<<1<<" "; else cout<<ans[i][j]<<" "; } cout<<endl; } } } } signed main() { // freopen("meta_game_input.txt","r",stdin); // freopen("otput.txt","w",stdout); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); preprocess(); //bla(); int t=1; cin>>t; while(t--) solve(); }
#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...