# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
850866 | 2023-09-17T15:01:27 Z | Itamar | Gardening (RMI21_gardening) | C++14 | 17 ms | 1368 KB |
// garden.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> using namespace std; #include <vector> #define vi vector<int> bool pos(int l1,int r1, int l2,int r2, int k,int c, vector<vi>& ans) { int n = (r1 - l1 + 1), m = (r2 - l2 + 1); if (n <= 0 || m <= 0)return 1; if (n % 2 || m % 2 || (n == m && k == (n / 2) + 1)||4 * k > n * m || k == ((n * m) / 4) - 1 || k < max(n / 2, m / 2) || (min(n, m) == 2 && k != max(n, m) / 2)) { return 0; } for (int i = l1; i <= r1; i++) { for (int j = l2; j <= l2 + 1; j++) { ans[i][j] = c + (i - l1) / 2; } } l2 += 2; k -= n / 2; c += n / 2; if (pos(l1, r1, l2, r2, k, c, ans))return 1; l2 -= 2; k += n / 2; c -= n / 2; for (int i = l1; i <= l1 + 1; i++) { for (int j = l2; j <= r2; j++) { ans[i][j] = c + (j - l2) / 2; } } l1 += 2; k -= m / 2; c += m / 2; if (pos(l1, r1, l2, r2, k, c, ans))return 1; l1 -= 2; k += m / 2; c -= m / 2; for (int i = l1; i <= r1; i++) { ans[i][l2] = c; ans[i][r2] = c; } for (int j = l2; j <= r2; j++) { ans[l1][j] = c; ans[r1][j] = c; } k--, c++, l1++, l2++, r1--, r2--; return pos(l1, r1, l2, r2, k, c, ans); } int main() { int t; cin >> t; ios_base::sync_with_stdio(false); cin.tie(NULL); for (int i = 0; i < t; i++) { int n, m, k; cin >> n >> m >> k; if (n % 2 || m % 2 || (n == m && k == (n / 2) + 1) || 4 * k > n * m || k == ((n * m) / 4) - 1 || k < max(n / 2, m / 2) || (min(n, m) == 2 && k != max(n, m) / 2)) { cout << "NO" << "\n"; continue; } cout << "YES" << "\n"; vector<vi> ans(n, vi(m)); ans.resize(n, vi(m)); pos(0,n-1,0, m-1, k, 1,ans); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cout << ans[i][j]; if (j < m - 1)cout << ' '; else cout << "\n"; } } } } // Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu // Tips for Getting Started: // 1. Use the Solution Explorer window to add/manage files // 2. Use the Team Explorer window to connect to source control // 3. Use the Output window to see build output and other messages // 4. Use the Error List window to view errors // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 788 KB | Correct! Azusa and Laika like the garden :) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 788 KB | Correct! Azusa and Laika like the garden :) |
2 | Correct | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
3 | Correct | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 788 KB | Correct! Azusa and Laika like the garden :) |
2 | Correct | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
3 | Correct | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
4 | Correct | 8 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
5 | Correct | 7 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
2 | Correct | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
3 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
4 | Correct | 6 ms | 756 KB | Correct! Azusa and Laika like the garden :) |
5 | Correct | 6 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
6 | Correct | 6 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
7 | Correct | 7 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
8 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
9 | Correct | 6 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
10 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
11 | Correct | 6 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
12 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
13 | Correct | 6 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
2 | Correct | 2 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
3 | Correct | 2 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
4 | Correct | 4 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
5 | Correct | 4 ms | 512 KB | Correct! Azusa and Laika like the garden :) |
6 | Correct | 2 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
7 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
8 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
9 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
10 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
11 | Correct | 2 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
12 | Correct | 3 ms | 432 KB | Correct! Azusa and Laika like the garden :) |
13 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
14 | Correct | 3 ms | 612 KB | Correct! Azusa and Laika like the garden :) |
15 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
16 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
17 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 788 KB | Correct! Azusa and Laika like the garden :) |
2 | Correct | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
3 | Correct | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
4 | Correct | 8 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
5 | Correct | 7 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
6 | Correct | 7 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
7 | Correct | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
8 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
9 | Correct | 6 ms | 756 KB | Correct! Azusa and Laika like the garden :) |
10 | Correct | 6 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
11 | Correct | 6 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
12 | Correct | 7 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
13 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
14 | Correct | 6 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
15 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
16 | Correct | 6 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
17 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
18 | Correct | 6 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
19 | Correct | 3 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
20 | Correct | 2 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
21 | Correct | 2 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
22 | Correct | 4 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
23 | Correct | 4 ms | 512 KB | Correct! Azusa and Laika like the garden :) |
24 | Correct | 2 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
25 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
26 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
27 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
28 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
29 | Correct | 2 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
30 | Correct | 3 ms | 432 KB | Correct! Azusa and Laika like the garden :) |
31 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
32 | Correct | 3 ms | 612 KB | Correct! Azusa and Laika like the garden :) |
33 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
34 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
35 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
36 | Correct | 9 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
37 | Correct | 9 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
38 | Correct | 12 ms | 948 KB | Correct! Azusa and Laika like the garden :) |
39 | Correct | 10 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
40 | Correct | 9 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
41 | Correct | 11 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
42 | Correct | 9 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
43 | Correct | 11 ms | 924 KB | Correct! Azusa and Laika like the garden :) |
44 | Correct | 11 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
45 | Correct | 9 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
46 | Correct | 9 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
47 | Correct | 10 ms | 804 KB | Correct! Azusa and Laika like the garden :) |
48 | Correct | 10 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
49 | Correct | 9 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
50 | Correct | 9 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
51 | Correct | 8 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
52 | Correct | 9 ms | 932 KB | Correct! Azusa and Laika like the garden :) |
53 | Correct | 11 ms | 872 KB | Correct! Azusa and Laika like the garden :) |
54 | Correct | 9 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
55 | Correct | 9 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
56 | Correct | 9 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
57 | Correct | 9 ms | 960 KB | Correct! Azusa and Laika like the garden :) |
58 | Correct | 14 ms | 1368 KB | Correct! Azusa and Laika like the garden :) |
59 | Correct | 9 ms | 944 KB | Correct! Azusa and Laika like the garden :) |
60 | Correct | 10 ms | 860 KB | Correct! Azusa and Laika like the garden :) |