# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1066724 | 2024-08-20T05:47:28 Z | 정민찬(#11123) | Gardening (RMI21_gardening) | C++17 | 15 ms | 928 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll,ll> pll; vector<vector<int>> a; int pv; bool flag; void go(int sx, int sy, int h, int w, int K) { if (K == h * w / 4 - 1) { flag = false; return; } if (K == h * w / 4) { for (int x=sx; x<sx+h; x+=2) { for (int y=sy; y<sy+w; y+=2) { a[x][y] = a[x+1][y] = a[x][y+1] = a[x+1][y+1] = ++ pv; } } return; } if (h == 2 || w == 2) { flag = false; return; } int red = h / 2 + w / 2 - 2; int diff = h * w / 4 - K; int nh = 4, nw = 4, nk; if (diff <= red) { if (h / 2 <= diff) { nh = h; nw = 4 + (diff - h / 2) * 2; } else nh = diff * 2; nk = (nh-2) * (nw-2) / 4; } else if (diff == red + 1) { if (h >= 6 && w >= 8) { nh = h; nw = w - 2; } else if (h >= 8 && w >= 6) { nh = h - 2; nw = w; } else { flag = false; return; } nk = (nh-2) * (nw-2) / 4 - 2; } else { nh = h; nw = w; nk = K - 1; } pv ++; for (int i=0; i<nh; i++) { a[sx + i][sy] = pv; a[sx + i][sy + nw - 1] = pv; } for (int i=0; i<nw; i++) { a[sx][sy + i] = pv; a[sx + nh - 1][sy + i] = pv; } go(sx + 1, sy + 1, nh - 2, nw - 2, nk); for (int x=sx; x<sx+h; x+=2) { for (int y=sy; y<sy+w; y+=2) { if (x < sx + nh && y < sy + nw) continue; a[x][y] = a[x+1][y] = a[x][y+1] = a[x+1][y+1] = ++ pv; } } } void run_case() { ll n, m, k; cin >> n >> m >> k; if (n % 2 || m % 2) { cout << "NO\n"; return; } if (k > n*m/4) { cout << "NO\n"; return; } a.assign(n, vector<int>(m, 0)); pv = 0; flag = true; go(0, 0, n, m, k); if (!flag) { cout << "NO\n"; return; } cout << "YES\n"; for (int i=0; i<n; i++) { for (int j=0; j<m; j++) { cout << a[i][j] << ' '; } cout << '\n'; } } int main() { ios_base :: sync_with_stdio(false); cin.tie(NULL); int tc; cin >> tc; while (tc --) { run_case(); } }
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
2 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
3 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
2 | Correct | 6 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 | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
5 | Correct | 9 ms | 920 KB | Correct! Azusa and Laika like the garden :) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
2 | Correct | 6 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
3 | Correct | 5 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
4 | Correct | 6 ms | 648 KB | Correct! Azusa and Laika like the garden :) |
5 | Correct | 6 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 | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
8 | Correct | 5 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 | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
11 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
12 | Correct | 5 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
13 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
2 | Correct | 2 ms | 456 KB | Correct! Azusa and Laika like the garden :) |
3 | Correct | 3 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
4 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
5 | Correct | 5 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
6 | Correct | 2 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
7 | Correct | 2 ms | 348 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 | 456 KB | Correct! Azusa and Laika like the garden :) |
12 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
13 | Correct | 3 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
14 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
15 | Correct | 2 ms | 348 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 :) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
2 | Correct | 6 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 | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
5 | Correct | 9 ms | 920 KB | Correct! Azusa and Laika like the garden :) |
6 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
7 | Correct | 6 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
8 | Correct | 5 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
9 | Correct | 6 ms | 648 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 | 600 KB | Correct! Azusa and Laika like the garden :) |
12 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
13 | Correct | 5 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 | 7 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
16 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
17 | Correct | 5 ms | 600 KB | Correct! Azusa and Laika like the garden :) |
18 | Correct | 6 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
19 | Correct | 2 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
20 | Correct | 2 ms | 456 KB | Correct! Azusa and Laika like the garden :) |
21 | Correct | 3 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
22 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
23 | Correct | 5 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
24 | Correct | 2 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
25 | Correct | 2 ms | 348 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 | 456 KB | Correct! Azusa and Laika like the garden :) |
30 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
31 | Correct | 3 ms | 348 KB | Correct! Azusa and Laika like the garden :) |
32 | Correct | 3 ms | 604 KB | Correct! Azusa and Laika like the garden :) |
33 | Correct | 2 ms | 348 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 | 8 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
38 | Correct | 8 ms | 864 KB | Correct! Azusa and Laika like the garden :) |
39 | Correct | 8 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
40 | Correct | 8 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
41 | Correct | 8 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
42 | Correct | 8 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
43 | Correct | 8 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
44 | Correct | 9 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
45 | Correct | 8 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
46 | Correct | 10 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
47 | Correct | 8 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
48 | Correct | 8 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
49 | Correct | 9 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
50 | Correct | 8 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
51 | Correct | 7 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
52 | Correct | 8 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
53 | Correct | 15 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
54 | Correct | 9 ms | 856 KB | Correct! Azusa and Laika like the garden :) |
55 | Correct | 8 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 | 12 ms | 928 KB | Correct! Azusa and Laika like the garden :) |
58 | Correct | 8 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
59 | Correct | 8 ms | 860 KB | Correct! Azusa and Laika like the garden :) |
60 | Correct | 8 ms | 860 KB | Correct! Azusa and Laika like the garden :) |