Submission #646811

#TimeUsernameProblemLanguageResultExecution timeMemory
646811ovidiush11Gardening (RMI21_gardening)C++14
5 / 100
123 ms624 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long void draw(ll n,ll m,ll k) { for(ll i = 0;i < k;i++) { for(ll j = 0;j < i;j++)cout<<j+1<<" "; for(ll j = i;j < m-i;j++)cout<<i+1<<" "; for(ll j = m-i;j < m;j++)cout<<m-j<<" "; cout<<endl; } ll x = k + 1,y = x,st = 0; for(ll i = k;i < n - k;i++) { for(ll j = 0;j < k;j++)cout<<j+1<<" "; for(ll j = k;j < m - k;j+=2) { cout<<x<<" "<<x<<" "; x++; } for(ll j = m-k;j < m;j++)cout<<m-j<<" "; cout<<endl; if(st == 0) { st++; x = y; } else { st--; y = x; } } for(ll i = k-1;i >= 0;i--) { for(ll j = 0;j < i;j++)cout<<j+1<<" "; for(ll j = i;j < m-i;j++)cout<<i+1<<" "; for(ll j = m-i;j < m;j++)cout<<m-j<<" "; cout<<endl; } return ; } void solve() { ll n,m,k; cin>>n>>m>>k; if(n % 2 == 1 || m % 2 == 1) { cout<<"NO"<<endl; return ; } ll s = -1; for(ll i = 0;i < min(n,m) / 2;i++) { ll x = (n * m - 2 * i * (n + m) + pow(2 * i,2)) / 4 + i; if(x == k) { s = i; break; } else if(x < k)break; } if(s == -1)cout<<"NO"<<endl; else { cout<<"YES"<<endl; draw(n,m,s); } return ; } int main() { ll 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...