Submission #869266

#TimeUsernameProblemLanguageResultExecution timeMemory
869266MinaRagy06Gardening (RMI21_gardening)C++17
0 / 100
15 ms1116 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 a[n][m]{}; int mx = (n / 2) * (m / 2); if (k > mx) { cout << "NO\n"; continue; } cout << "YES\n"; bool must[n][n]{}; for (int i = 0; i < n && k; i += 2) { for (int j = 0; j < 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]; } else if (j - 1 >= 0) { a[i][j] = a[i][j - 1]; } else if (i - 1 >= 0) { a[i][j] = a[i - 1][j]; } } } 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...