Submission #570698

#TimeUsernameProblemLanguageResultExecution timeMemory
570698Theo830Gardening (RMI21_gardening)C++17
0 / 100
24 ms724 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ii,ll> #define ull unsigned ll #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training int main(void){ ios_base::sync_with_stdio(0); cin.tie(0); ll t; cin>>t; while(t--){ ll n,m,k; cin>>n>>m>>k; bool ok = 1; if(n % 2 == 1 && m % 2 == 1){ ok = 0; } else if(k > (n / 2) * (m / 2)){ ok = 0; } else if(k < max(n / 2,m / 2)){ ok = 0; } if(!ok){ cout<<"NO\n"; } else{ ll ans[n][m]; ll cur = 1; f(i,0,n){ f(j,0,m){ if(cur <= k){ ans[i][j] = ans[i][j+1] = ans[i+1][j] = ans[i+1][j+1] = cur; } else{ if(n <= m){ ans[i][j] = ans[i][j+1] = ans[i+1][j] = ans[i+1][j+1] = ans[i-1][j]; } else{ ans[i][j] = ans[i][j+1] = ans[i+1][j] = ans[i+1][j+1] = ans[i][j-1]; } } cur++; j++; } if(m % 2 == 1){ ans[i][m - 1] = ans[i][m - 2]; } i++; } if(n % 2 == 1){ f(j,0,m){ ans[n-1][j] = ans[n-2][j]; } } cout<<"YES\n"; f(i,0,n){ f(j,0,m){ cout<<ans[i][j]<<" "; } cout<<"\n"; } } } }
#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...