# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
99610 | 2019-03-05T15:57:53 Z | lovemathboy | Dango Maker (JOI18_dango_maker) | C++14 | 375 ms | 81880 KB |
#include <bits/stdc++.h> using namespace std; int n, m; char a[3005][3005]; int memo[3005][3005][2]; inline bool hori(int x, int y) { if (y + 2 >= m) return false; if (a[x][y] == 'R' && a[x][y+1] == 'G' && a[x][y+2] == 'W') return true; return false; } inline bool vert(int x, int y) { if (x + 2 >= n) return false; if (a[x][y] == 'R' && a[x+1][y] == 'G' && a[x+2][y] == 'W') return true; return false; } int main() { scanf("%d %d", &n, &m); for (int i = 0; i < n; i++) { scanf("%s", a[i]); for (int j = 0; j < m; j++) memo[i][j][0] = 0, memo[i][j][1] = 0; } int ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j <= i; j++) { if (j > 0) { memo[i-j][j][0] = max(memo[i-j+1][j-1][0], memo[i-j+1][j-1][1]); memo[i-j][j][1] = memo[i-j+1][j-1][1]; } if (j > 2) { memo[i-j][j][1] = max(memo[i-j][j][1], memo[i-j+3][j-3][0]); } if (a[i-j][j] != 'R') continue; if (hori(i-j, j)) memo[i-j][j][0]++; if (vert(i-j, j)) memo[i-j][j][1]++; } } for (int i = 1; i < m; i++) { for (int j = 0; j < m-i; j++) { if (i+j >= m || n-j-1 < 0) break; if (j > 0) { memo[n-j-1][i+j][0] = max(memo[n-j][i+j-1][0], memo[n-j][i+j-1][1]); memo[n-j-1][i+j][1] = memo[n-j][i+j-1][1]; } if (j > 2) { memo[n-j-1][i+j][1] = max(memo[n-j][i+j-1][1], memo[n-j+2][i+j-3][0]); } if (a[n-j-1][i+j] != 'R') continue; if (hori(n-j-1, i+j)) memo[n-j-1][i+j][0]++; if (vert(n-j-1, i+j)) memo[n-j-1][i+j][1]++; } } for (int i = 0; i < m; i++) { ans += max(memo[0][i][0], memo[0][i][1]); } for (int i = 1; i < n; i++) { ans += max(memo[i][m-1][0], memo[i][m-1][1]); } printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 3 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 2 ms | 384 KB | Output is correct |
23 | Correct | 3 ms | 512 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 2 ms | 384 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
29 | Correct | 2 ms | 384 KB | Output is correct |
30 | Correct | 2 ms | 384 KB | Output is correct |
31 | Correct | 3 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 384 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 3 ms | 384 KB | Output is correct |
35 | Correct | 2 ms | 384 KB | Output is correct |
36 | Correct | 3 ms | 412 KB | Output is correct |
37 | Correct | 2 ms | 384 KB | Output is correct |
38 | Correct | 2 ms | 384 KB | Output is correct |
39 | Correct | 2 ms | 384 KB | Output is correct |
40 | Correct | 3 ms | 384 KB | Output is correct |
41 | Correct | 2 ms | 384 KB | Output is correct |
42 | Correct | 2 ms | 384 KB | Output is correct |
43 | Correct | 2 ms | 384 KB | Output is correct |
44 | Correct | 2 ms | 384 KB | Output is correct |
45 | Correct | 2 ms | 384 KB | Output is correct |
46 | Correct | 2 ms | 384 KB | Output is correct |
47 | Correct | 2 ms | 384 KB | Output is correct |
48 | Correct | 2 ms | 384 KB | Output is correct |
49 | Correct | 2 ms | 384 KB | Output is correct |
50 | Correct | 2 ms | 384 KB | Output is correct |
51 | Correct | 2 ms | 384 KB | Output is correct |
52 | Correct | 3 ms | 384 KB | Output is correct |
53 | Correct | 3 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 3 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 2 ms | 384 KB | Output is correct |
23 | Correct | 3 ms | 512 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 3 ms | 384 KB | Output is correct |
26 | Correct | 2 ms | 384 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
29 | Correct | 2 ms | 384 KB | Output is correct |
30 | Correct | 2 ms | 384 KB | Output is correct |
31 | Correct | 3 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 384 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 3 ms | 384 KB | Output is correct |
35 | Correct | 2 ms | 384 KB | Output is correct |
36 | Correct | 3 ms | 412 KB | Output is correct |
37 | Correct | 2 ms | 384 KB | Output is correct |
38 | Correct | 2 ms | 384 KB | Output is correct |
39 | Correct | 2 ms | 384 KB | Output is correct |
40 | Correct | 3 ms | 384 KB | Output is correct |
41 | Correct | 2 ms | 384 KB | Output is correct |
42 | Correct | 2 ms | 384 KB | Output is correct |
43 | Correct | 2 ms | 384 KB | Output is correct |
44 | Correct | 2 ms | 384 KB | Output is correct |
45 | Correct | 2 ms | 384 KB | Output is correct |
46 | Correct | 2 ms | 384 KB | Output is correct |
47 | Correct | 2 ms | 384 KB | Output is correct |
48 | Correct | 2 ms | 384 KB | Output is correct |
49 | Correct | 2 ms | 384 KB | Output is correct |
50 | Correct | 2 ms | 384 KB | Output is correct |
51 | Correct | 2 ms | 384 KB | Output is correct |
52 | Correct | 3 ms | 384 KB | Output is correct |
53 | Correct | 3 ms | 384 KB | Output is correct |
54 | Correct | 2 ms | 384 KB | Output is correct |
55 | Correct | 153 ms | 55416 KB | Output is correct |
56 | Correct | 3 ms | 512 KB | Output is correct |
57 | Correct | 83 ms | 29816 KB | Output is correct |
58 | Correct | 42 ms | 16120 KB | Output is correct |
59 | Correct | 355 ms | 81628 KB | Output is correct |
60 | Correct | 349 ms | 81656 KB | Output is correct |
61 | Correct | 375 ms | 81656 KB | Output is correct |
62 | Correct | 3 ms | 384 KB | Output is correct |
63 | Correct | 359 ms | 81624 KB | Output is correct |
64 | Correct | 337 ms | 81880 KB | Output is correct |
65 | Correct | 327 ms | 81604 KB | Output is correct |
66 | Correct | 327 ms | 81656 KB | Output is correct |
67 | Correct | 315 ms | 81656 KB | Output is correct |
68 | Correct | 311 ms | 81568 KB | Output is correct |
69 | Correct | 312 ms | 81524 KB | Output is correct |
70 | Correct | 34 ms | 16248 KB | Output is correct |
71 | Correct | 29 ms | 16128 KB | Output is correct |
72 | Correct | 25 ms | 16120 KB | Output is correct |
73 | Correct | 28 ms | 16128 KB | Output is correct |
74 | Correct | 28 ms | 16128 KB | Output is correct |
75 | Correct | 26 ms | 16128 KB | Output is correct |
76 | Correct | 38 ms | 16120 KB | Output is correct |
77 | Correct | 25 ms | 16120 KB | Output is correct |
78 | Correct | 31 ms | 16128 KB | Output is correct |
79 | Correct | 29 ms | 16128 KB | Output is correct |
80 | Correct | 31 ms | 16120 KB | Output is correct |
81 | Correct | 35 ms | 16120 KB | Output is correct |
82 | Correct | 28 ms | 16120 KB | Output is correct |
83 | Correct | 53 ms | 16128 KB | Output is correct |
84 | Correct | 29 ms | 16120 KB | Output is correct |
85 | Correct | 32 ms | 16128 KB | Output is correct |
86 | Correct | 29 ms | 16116 KB | Output is correct |
87 | Correct | 30 ms | 16128 KB | Output is correct |
88 | Correct | 27 ms | 16128 KB | Output is correct |
89 | Correct | 34 ms | 16128 KB | Output is correct |
90 | Correct | 28 ms | 16120 KB | Output is correct |