제출 #770766

#제출 시각아이디문제언어결과실행 시간메모리
770766gg123_peGardening (RMI21_gardening)C++14
0 / 100
16 ms624 KiB
#include <bits/stdc++.h> using namespace std; #define f(i,a,b) for(int i = a; i < b; i++) bool fe; int c; pair<int,int> range(int n, int m){ if(n == 2) return {m/2, m/2}; return {n*m/4 - m/2, n*m/4}; } void print(vector <vector<int>> v){ int n = v.size(), m = v[0].size(); if(!fe){ f(i,0,n) { f(j,0,m) cout << ((v[i][j] == 0) ? c : v[i][j]) << " "; cout << "\n"; } } else{ f(i,0,m) { f(j,0,n) cout << ((v[j][i] == 0) ? c : v[j][i]) << " "; cout << "\n"; } } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while(t--){ int n, m, k; cin >> n >> m >> k; if(n&1 or m&1){ cout << "NO\n"; continue; } fe = 0; if(n > m) { fe = 1; swap(n, m); } pair<int,int> p = range(n, m); if(p.second < k or k < p.first){ cout << "NO\n"; continue; } vector <vector<int>> v(n, vector <int> (m)); bool ra = 0; if(n == 2){ c = 1; for(int i = 0; i < m; i += 2){ v[0][i] = v[0][i+1] = c; v[1][i] = v[1][i+1] = c; c++; } } else{ c = 1; for(int i = 0; i < n-4; i += 2){ for(int j = 0; j < m; j += 2){ v[i][j] = v[i][j+1] = c; v[i+1][j] = v[i+1][j+1] = c; c++; k--; } } int L = 2*k - m; if(m - L < 4){ cout << "NO\n"; ra = 1; } for(int i = 0; i < L; i += 2){ f(r, n-4, n-2) f(s, i, i+2) v[r][s] = c; c++; f(r, n-2, n) f(s, i, i+2) v[r][s] = c; c++; } for(int i = L+1; i < m-1; i += 2){ f(r, n-3, n-1) f(s, i, i+2) v[r][s] = c; c++; } } if(!ra){ cout << "YES\n"; print(v); } } 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...