# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
736931 | 2023-05-06T11:20:02 Z | puppy | Gardening (RMI21_gardening) | C++17 | 25 ms | 872 KB |
#include <iostream> #include <vector> #include <cassert> using namespace std; bool check(int N, int M, int K) { if (N % 2 || M % 2) return false; if (K < max(N/2, M/2)) return false; if (K > N * M / 4) return false; if (K == N * M / 4 - 1) return false; if (N == M && K == N / 2 + 1) return false; return true; } vector<vector<int>> v; void color(int n, int m, int st, int x, int y) { if (n == 2) { //st부터 k개의 색을 채우기 for (int i = y; i <= y + m - 1; i++) { int clr = (i - y) / 2 + st; v[x][i] = v[x+1][i] = clr; } return; } else if (m == 2) { for (int i = x; i <= x + n - 1; i++) { int clr = (i - x) / 2 + st; v[i][y] = v[i][y+1] = clr; } return; } } void fillin(int n, int m, int st, int k, int x, int y) //(x, y)부터 (n, m)칸 채우기 { if (n == 2 || m == 2) color(n, m, st, x, y); else { if (check(n, m-2, k-n/2)) { fillin(n, m-2, st, k-n/2, x, y); color(n, 2, st+k-n/2, x, y+m-2); } else if (check(n-2, m, k-m/2)) { fillin(n-2, m, st, k-m/2, x, y); color(2, m, st+k-m/2, x+n-2, y); } else if (check(n-2, m-2, k-1)) { for (int j = y; j < y + m; j++) v[x][j] = v[x+n-1][j] = st; for (int i = x; i < x + n; i++) v[i][y] = v[i][y+m-1] = st; fillin(n-2, m-2, st+1, k-1, x+1, y+1); } } } void solve() { int N, M, K; cin >> N >> M >> K; v.resize(N); for (int i = 0; i < N; i++) v[i].resize(M); if (!check(N, M, K)) { cout << "NO\n"; return; } fillin(N, M, 1, K, 0, 0); cout << "YES\n"; for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { cout << v[i][j] << ' '; } cout << '\n'; } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int T; cin >> T; while (T--) { solve(); } }
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 724 KB | Correct! Azusa and Laika like the garden :) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 724 KB | Correct! Azusa and Laika like the garden :) |
2 | Correct | 13 ms | 520 KB | Correct! Azusa and Laika like the garden :) |
3 | Correct | 10 ms | 580 KB | Correct! Azusa and Laika like the garden :) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 724 KB | Correct! Azusa and Laika like the garden :) |
2 | Correct | 13 ms | 520 KB | Correct! Azusa and Laika like the garden :) |
3 | Correct | 10 ms | 580 KB | Correct! Azusa and Laika like the garden :) |
4 | Correct | 10 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
5 | Correct | 14 ms | 652 KB | Correct! Azusa and Laika like the garden :) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
2 | Correct | 8 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
3 | Correct | 8 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
4 | Correct | 9 ms | 648 KB | Correct! Azusa and Laika like the garden :) |
5 | Correct | 11 ms | 632 KB | Correct! Azusa and Laika like the garden :) |
6 | Correct | 9 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
7 | Correct | 9 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
8 | Correct | 9 ms | 576 KB | Correct! Azusa and Laika like the garden :) |
9 | Correct | 8 ms | 576 KB | Correct! Azusa and Laika like the garden :) |
10 | Correct | 9 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
11 | Correct | 9 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
12 | Correct | 9 ms | 572 KB | Correct! Azusa and Laika like the garden :) |
13 | Correct | 9 ms | 548 KB | Correct! Azusa and Laika like the garden :) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
2 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
3 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
4 | Correct | 5 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
5 | Correct | 5 ms | 528 KB | Correct! Azusa and Laika like the garden :) |
6 | Correct | 4 ms | 444 KB | Correct! Azusa and Laika like the garden :) |
7 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
8 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
9 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
10 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
11 | Correct | 3 ms | 340 KB | Correct! Azusa and Laika like the garden :) |
12 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
13 | Correct | 5 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
14 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
15 | Correct | 6 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
16 | Correct | 4 ms | 448 KB | Correct! Azusa and Laika like the garden :) |
17 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 724 KB | Correct! Azusa and Laika like the garden :) |
2 | Correct | 13 ms | 520 KB | Correct! Azusa and Laika like the garden :) |
3 | Correct | 10 ms | 580 KB | Correct! Azusa and Laika like the garden :) |
4 | Correct | 10 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
5 | Correct | 14 ms | 652 KB | Correct! Azusa and Laika like the garden :) |
6 | Correct | 9 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
7 | Correct | 8 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
8 | Correct | 8 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
9 | Correct | 9 ms | 648 KB | Correct! Azusa and Laika like the garden :) |
10 | Correct | 11 ms | 632 KB | Correct! Azusa and Laika like the garden :) |
11 | Correct | 9 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
12 | Correct | 9 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
13 | Correct | 9 ms | 576 KB | Correct! Azusa and Laika like the garden :) |
14 | Correct | 8 ms | 576 KB | Correct! Azusa and Laika like the garden :) |
15 | Correct | 9 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
16 | Correct | 9 ms | 596 KB | Correct! Azusa and Laika like the garden :) |
17 | Correct | 9 ms | 572 KB | Correct! Azusa and Laika like the garden :) |
18 | Correct | 9 ms | 548 KB | Correct! Azusa and Laika like the garden :) |
19 | Correct | 3 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
20 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
21 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
22 | Correct | 5 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
23 | Correct | 5 ms | 528 KB | Correct! Azusa and Laika like the garden :) |
24 | Correct | 4 ms | 444 KB | Correct! Azusa and Laika like the garden :) |
25 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
26 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
27 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
28 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
29 | Correct | 3 ms | 340 KB | Correct! Azusa and Laika like the garden :) |
30 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
31 | Correct | 5 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
32 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
33 | Correct | 6 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
34 | Correct | 4 ms | 448 KB | Correct! Azusa and Laika like the garden :) |
35 | Correct | 4 ms | 468 KB | Correct! Azusa and Laika like the garden :) |
36 | Correct | 12 ms | 724 KB | Correct! Azusa and Laika like the garden :) |
37 | Correct | 12 ms | 828 KB | Correct! Azusa and Laika like the garden :) |
38 | Correct | 13 ms | 724 KB | Correct! Azusa and Laika like the garden :) |
39 | Correct | 13 ms | 828 KB | Correct! Azusa and Laika like the garden :) |
40 | Correct | 13 ms | 872 KB | Correct! Azusa and Laika like the garden :) |
41 | Correct | 12 ms | 724 KB | Correct! Azusa and Laika like the garden :) |
42 | Correct | 12 ms | 768 KB | Correct! Azusa and Laika like the garden :) |
43 | Correct | 15 ms | 740 KB | Correct! Azusa and Laika like the garden :) |
44 | Correct | 13 ms | 724 KB | Correct! Azusa and Laika like the garden :) |
45 | Correct | 12 ms | 724 KB | Correct! Azusa and Laika like the garden :) |
46 | Correct | 12 ms | 724 KB | Correct! Azusa and Laika like the garden :) |
47 | Correct | 15 ms | 812 KB | Correct! Azusa and Laika like the garden :) |
48 | Correct | 13 ms | 724 KB | Correct! Azusa and Laika like the garden :) |
49 | Correct | 13 ms | 756 KB | Correct! Azusa and Laika like the garden :) |
50 | Correct | 12 ms | 776 KB | Correct! Azusa and Laika like the garden :) |
51 | Correct | 12 ms | 696 KB | Correct! Azusa and Laika like the garden :) |
52 | Correct | 13 ms | 724 KB | Correct! Azusa and Laika like the garden :) |
53 | Correct | 13 ms | 828 KB | Correct! Azusa and Laika like the garden :) |
54 | Correct | 14 ms | 724 KB | Correct! Azusa and Laika like the garden :) |
55 | Correct | 13 ms | 724 KB | Correct! Azusa and Laika like the garden :) |
56 | Correct | 13 ms | 764 KB | Correct! Azusa and Laika like the garden :) |
57 | Correct | 13 ms | 852 KB | Correct! Azusa and Laika like the garden :) |
58 | Correct | 13 ms | 724 KB | Correct! Azusa and Laika like the garden :) |
59 | Correct | 14 ms | 832 KB | Correct! Azusa and Laika like the garden :) |
60 | Correct | 12 ms | 832 KB | Correct! Azusa and Laika like the garden :) |