# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
871713 | 2023-11-11T11:11:18 Z | TAhmed33 | Gardening (RMI21_gardening) | C++ | 19 ms | 956 KB |
#include <bits/stdc++.h> using namespace std; /* const int n = 20; bool dp[n + 1][n + 1][n * n + 1]; int main () { for (int i = 2; i <= n; i += 2) { for (int j = 2; j <= n; j += 2) { for (int k = 1; k <= i * j; k++) { if (i == 2 && j == 2 && k == 1) { dp[i][j][k] = 1; continue; } dp[i][j][k] = dp[i - 2][j - 2][k - 1]; for (int l = 1; l < k; l++) { for (int s = 2; s < i; s += 2) { dp[i][j][k] |= dp[s][j][l] & dp[i - s][j][k - l]; } for (int s = 2; s < j; s += 2) { dp[i][j][k] |= dp[i][s][l] & dp[i][j - s][k - l]; } } } } } for (int i = 2; i <= n; i += 2) { for (int j = 2; j <= n; j += 2) { for (int l = 1; l <= i * j; l++) { if (dp[i][j][l]) { cout << "YES: " << i << " " << j << " " << l << '\n'; } else { cout << "NO: " << i << " " << j << " " << l << '\n'; } } } } n and m are even max(n / 2, m / 2) <= k <= n * m / 4, k != n * m / 4 - 1 if n == m then k != n / 2 - 1 pattern observation level el wa7sh }*/ vector <vector <int>> arr; int cnt = 0; bool valid (int n, int m, int k) { if (n <= 0 || m <= 0 || k <= 0) return 0; if (n & 1) return 0; if (m & 1) return 0; if (max(n / 2, m / 2) > k || k > n * m / 4 || k == n * m / 4 - 1 || (n == m && k == n / 2 + 1)) return 0; return 1; } void recurse (int x1, int y1, int x2, int y2, int k) { if (k == 0 || x1 > x2 || y1 > y2) return; int n = x2 - x1 + 1, m = y2 - y1 + 1; assert(valid(n, m, k)); if (valid(n - 2, m - 2, k - 1)) { cnt++; for (int i = x1; i <= x2; i++) arr[i][y1] = arr[i][y2] = cnt; for (int i = y1; i <= y2; i++) arr[x1][i] = arr[x2][i] = cnt; recurse(x1 + 1, y1 + 1, x2 - 1, y2 - 1, k - 1); return; } if (k == n * m / 4) { for (int i = x1; i < x2; i += 2) { for (int j = y1; j < y2; j += 2) { cnt++; arr[i][j] = arr[i][j + 1] = arr[i + 1][j] = arr[i + 1][j + 1] = cnt; } } return; } for (int z = 1; z < k; z++) { for (int l = 2; l < n; l += 2) { if (valid(l, m, z) && valid(n - l, m, k - z)) { recurse(x1, y1, x1 + l - 1, y2, z); recurse(x1 + l, y1, x2, y2, k - z); return; } } for (int l = 2; l < m; l += 2) { if (valid(n, l, z) && valid(n, m - l, k - z)) { recurse(x1, y1, x2, y1 + l - 1, z); recurse(x1, y1 + l, x2, y2, k - z); return; } } } } int main () { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int n, m, k; cin >> n >> m >> k; if (!valid(n, m, k)) { cout << "NO\n"; continue; } cout << "YES\n"; arr.clear(); arr = vector <vector <int>> (n + 1, vector <int> (m + 1)); cnt = 0; recurse(1, 1, n, m, k); assert(k == cnt); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cout << arr[i][j] << " "; } cout << '\n'; } cout << '\n'; } }
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 860 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 | 600 KB | Correct! Azusa and Laika like the garden :) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 860 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 | 600 KB | Correct! Azusa and Laika like the garden :) |
4 | Correct | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
5 | Correct | 8 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 740 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 | 780 KB | Correct! Azusa and Laika like the garden :) |
4 | Correct | 7 ms | 672 KB | Correct! Azusa and Laika like the garden :) |
5 | Correct | 7 ms | 604 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 | 604 KB | Correct! Azusa and Laika like the garden :) |
8 | Correct | 7 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
9 | Correct | 7 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
10 | Correct | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
11 | Correct | 8 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 :) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 348 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 | 604 KB | Correct! Azusa and Laika like the garden :) |
6 | Correct | 3 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
7 | Correct | 3 ms | 456 KB | Correct! Azusa and Laika like the garden :) |
8 | Correct | 3 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
9 | Correct | 3 ms | 600 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 | 456 KB | Correct! Azusa and Laika like the garden :) |
12 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
13 | Correct | 5 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
14 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
15 | Correct | 3 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
16 | Correct | 3 ms | 584 KB | Correct! Azusa and Laika like the garden :) |
17 | Correct | 4 ms | 456 KB | Correct! Azusa and Laika like the garden :) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 860 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 | 600 KB | Correct! Azusa and Laika like the garden :) |
4 | Correct | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
5 | Correct | 8 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
6 | Correct | 10 ms | 740 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 | 780 KB | Correct! Azusa and Laika like the garden :) |
9 | Correct | 7 ms | 672 KB | Correct! Azusa and Laika like the garden :) |
10 | Correct | 7 ms | 604 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 | 604 KB | Correct! Azusa and Laika like the garden :) |
13 | Correct | 7 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
14 | Correct | 7 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
15 | Correct | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
16 | Correct | 8 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 | 348 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 | 604 KB | Correct! Azusa and Laika like the garden :) |
24 | Correct | 3 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
25 | Correct | 3 ms | 456 KB | Correct! Azusa and Laika like the garden :) |
26 | Correct | 3 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
27 | Correct | 3 ms | 600 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 | 456 KB | Correct! Azusa and Laika like the garden :) |
30 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
31 | Correct | 5 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
32 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
33 | Correct | 3 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
34 | Correct | 3 ms | 584 KB | Correct! Azusa and Laika like the garden :) |
35 | Correct | 4 ms | 456 KB | Correct! Azusa and Laika like the garden :) |
36 | Correct | 10 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
37 | Correct | 12 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
38 | Correct | 10 ms | 956 KB | Correct! Azusa and Laika like the garden :) |
39 | Correct | 10 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
40 | Correct | 9 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
41 | Correct | 10 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
42 | Correct | 10 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
43 | Correct | 10 ms | 860 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 | 856 KB | Correct! Azusa and Laika like the garden :) |
46 | Correct | 9 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
47 | Correct | 14 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
48 | Correct | 10 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
49 | Correct | 10 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
50 | Correct | 10 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
51 | Correct | 10 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
52 | Correct | 10 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
53 | Correct | 10 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
54 | Correct | 10 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
55 | Correct | 9 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
56 | Correct | 10 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
57 | Correct | 10 ms | 760 KB | Correct! Azusa and Laika like the garden :) |
58 | Correct | 10 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
59 | Correct | 10 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
60 | Correct | 10 ms | 860 KB | Correct! Azusa and Laika like the garden :) |