# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
991705 | Abito | Gardening (RMI21_gardening) | C++17 | 11 ms | 856 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>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define y1 YONE
typedef unsigned long long ull;
using namespace std;
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int t;cin>>t;
while (t--){
int n,m,k;
cin>>n>>m>>k;
if ((n&1)||(m&1)){
cout<<"NO"<<endl;
continue;
}
if (n==2){
if (k!=m/2){
cout<<"NO"<<endl;
continue;
}cout<<"YES"<<endl;
for (int i=1;i<=m/2;i++) cout<<i<<' '<<i<<' ';cout<<endl;
for (int i=1;i<=m/2;i++) cout<<i<<' '<<i<<' ';cout<<endl;
continue;
}
int idx=-1;
for (int i=0;i<=m/2;i++){
if (i+m/2==k) idx=i;
}
if (-1==idx || idx==m/2-1){
cout<<"NO"<<endl;
continue;
}//cout<<idx<<endl;
cout<<"YES"<<endl;
int c=1,a[n+5][m+5]={0};
for (int i=1;i<=2*idx;i+=2){
a[1][i]=a[2][i]=a[1][i+1]=a[2][i+1]=c;
c++;
a[3][i]=a[4][i]=a[3][i+1]=a[4][i+1]=c;
c++;
}
if (2*idx==m){
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++) cout<<a[i][j]<<' ';
cout<<endl;
}
continue;
}
for (int j=1;j<=4;j++) a[j][2*idx+1]=a[j][m]=c;
c++;
for (int i=2*idx+2;i<m;i+=2){
a[1][i]=a[4][i]=a[1][i+1]=a[4][i+1]=a[1][m];
a[2][i]=a[3][i]=a[2][i+1]=a[3][i+1]=c;
c++;
}
for (int i=1;i<=n;i++){
for (int j=1;j<=m;j++) cout<<a[i][j]<<' ';
cout<<endl;
}
}
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... |