Submission #742335

#TimeUsernameProblemLanguageResultExecution timeMemory
742335hmm789Gardening (RMI21_gardening)C++14
11 / 100
17 ms724 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int32_t 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 % 2 == 1 || m % 2 == 1) { cout << "NO\n"; continue; } if(n == 2) { if(k == m/2) { cout << "YES\n"; for(int i = 0; i < m; i++) cout << i/2+1 << " "; cout << '\n'; for(int i = 0; i < m; i++) cout << i/2+1 << " "; cout << '\n'; } else cout << "NO\n"; } else { if(k < m/2 || k == m-1 || k > m) cout << "NO\n"; else { cout << "YES\n"; vector<int> v; int cur = m-k; if(cur % 2 == 1) { v.push_back(6); cur -= 3; } for(int i = 0; i < cur/2; i++) { v.push_back(4); } cur = 0; for(int i : v) cur += i; for(int i = 0; i < m-cur; i+=2) v.push_back(2); int cols = 1; vector<int> first, sec, thi; for(int i : v) { for(int j = 0; j < i; j++) { cout << cols << " "; first.push_back(cols); } cols++; } cout << '\n'; cur = 0; for(int i : v) { cout << first[cur] << " "; sec.push_back(first[cur]); cur++; if(i == 4) { for(int j = 0; j < i-2; j++) { cout << cols << " "; sec.push_back(cols); cur++; } cols++; } if(i == 6) { for(int j = 0; j < 2; j++) { cout << cols << " "; sec.push_back(cols); cur++; } cols++; for(int j = 0; j < 2; j++) { cout << cols << " "; sec.push_back(cols); cur++; } cols++; } cout << first[cur] << " "; sec.push_back(first[cur]); cur++; } cout << '\n'; cur = 0; for(int i : v) { if(i > 2) { for(int j = 0; j < i; j++) { cout << sec[cur] << " "; cur++; thi.push_back(sec[cur]); } } else { for(int j = 0; j < i; j++) { cout << cols << " "; cur++; thi.push_back(cols); } cols++; } } cout << '\n'; cur = 0; for(int i : v) { if(i > 2) { for(int j = 0; j < i; j++) { cout << first[cur] << " "; cur++; } } else { for(int j = 0; j < i; j++) { cout << thi[cur] << " "; cur++; } } } 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...