# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
645463 | TimDee | Gardening (RMI21_gardening) | C++17 | 23 ms | 972 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for (int i=0;i<n;++i)
void solve() {
int n,m,k; cin>>n>>m>>k;
int s=n*m;
if (k>(s/2)) {
cout<<"NO\n";
return;
}
cout<<"YES\n";
if (m==1) {
forn(i,k*(n/k)) cout<<(i/(n/k))+1<<'\n';
for (int i=k*(n/k);i<n;++i) cout<<k<<'\n';
return;
}
int cnt=1;
vector<vector<int>> a(n,vector<int>(m,k));
if (m&1) {
for (int i=0; i<m && cnt<k; ++i) {
if (i&1) {
for (int j=m-2; j>=0 && cnt<k; j-=2) {
a[i][j]=cnt;
a[i][j-1]=cnt;
++cnt;
}
} else {
for (int j=0; j<m && cnt<k; j+=2) {
a[i][j]=cnt;
a[i][j+1]=cnt;
++cnt;
}
if (cnt<k) {
a[i][m-1]=a[i+1][m-1]=cnt++;
}
}
}
}
for (auto x:a) {
for (auto y:x) cout<<y<<' '; cout<<'\n';
}
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t; cin>>t;
while (t--) solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |