Submission #869269

#TimeUsernameProblemLanguageResultExecution timeMemory
869269MinaRagy06Gardening (RMI21_gardening)C++17
0 / 100
15 ms860 KiB
#include <bits/stdc++.h> using namespace std; typedef int64_t ll; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int t; cin >> t; while (t--) { int n, m, k; cin >> n >> m >> k; int mx = (n / 2) * (m / 2); if (k > mx) { cout << "NO\n"; continue; } bool swapped = 0; if (n < m) swap(n, m), swapped = 1; cout << "YES\n"; int a[n][m]{}; bool must[n][m]{}; for (int i = 0; i + 1 < n && k; i += 2) { for (int j = 0; j + 1 < m && k; j += 2) { a[i][j] = k--; must[i][j] = 1; } } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (a[i][j]) continue; if (i - 1 >= 0 && must[i - 1][j]) { a[i][j] = a[i - 1][j]; must[i][j] = 1; } else if (j - 1 >= 0) { a[i][j] = a[i][j - 1]; } else if (i - 1 >= 0) { a[i][j] = a[i - 1][j]; } } } if (swapped) { for (int j = 0; j < m; j++) { for (int i = 0; i < n; i++) { cout << a[i][j] << ' '; } cout << '\n'; } } else { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cout << a[i][j] << ' '; } cout << '\n'; } } } 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...