답안 #653146

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
653146 2022-10-25T19:51:34 Z someone Dango Maker (JOI18_dango_maker) C++14
100 / 100
274 ms 161204 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 3e3 + 42;

char c[N][N];
int n, m, dp[N][N][2];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    cin >> n >> m;
    n += 3;
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            c[i][j] = '#';
    for(int i = 3; i < n; i++)
        for(int j = 0; j < m; j++)
            cin >> c[i][j];
    int ans = 0;
    for(int i = 3; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(c[i][j] == 'R' && c[i+1][j] == 'G' && c[i+2][j] == 'W') {
                dp[i][j][0] = max(dp[i-1][j+1][0], dp[i-1][j+1][1]) + 1;
            }
            if(c[i][j] == 'R' && c[i][j+1] == 'G' && c[i][j+2] == 'W') {
                dp[i][j][1] = max(dp[i-3][j+3][0], dp[i-1][j+1][1]) + 1;
            }
            
            dp[i][j][1] = max(dp[i][j][1], dp[i-2][j+2][0]);
            dp[i][j][1] = max(dp[i][j][1], dp[i-1][j+1][1]);
            
            dp[i][j][0] = max(dp[i][j][0], dp[i][j][1]);
            dp[i][j][0] = max(dp[i][j][0], dp[i-1][j+1][0]);
        
            if(i == n-1 || j == 0)
                ans += dp[i][j][0];
        }
    }
    
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9300 KB Output is correct
2 Correct 4 ms 9284 KB Output is correct
3 Correct 4 ms 9300 KB Output is correct
4 Correct 5 ms 9300 KB Output is correct
5 Correct 4 ms 9300 KB Output is correct
6 Correct 4 ms 9300 KB Output is correct
7 Correct 5 ms 9300 KB Output is correct
8 Correct 4 ms 9300 KB Output is correct
9 Correct 5 ms 9300 KB Output is correct
10 Correct 5 ms 9300 KB Output is correct
11 Correct 5 ms 9288 KB Output is correct
12 Correct 4 ms 9300 KB Output is correct
13 Correct 4 ms 9300 KB Output is correct
14 Correct 4 ms 9300 KB Output is correct
15 Correct 5 ms 9300 KB Output is correct
16 Correct 4 ms 9300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9300 KB Output is correct
2 Correct 4 ms 9284 KB Output is correct
3 Correct 4 ms 9300 KB Output is correct
4 Correct 5 ms 9300 KB Output is correct
5 Correct 4 ms 9300 KB Output is correct
6 Correct 4 ms 9300 KB Output is correct
7 Correct 5 ms 9300 KB Output is correct
8 Correct 4 ms 9300 KB Output is correct
9 Correct 5 ms 9300 KB Output is correct
10 Correct 5 ms 9300 KB Output is correct
11 Correct 5 ms 9288 KB Output is correct
12 Correct 4 ms 9300 KB Output is correct
13 Correct 4 ms 9300 KB Output is correct
14 Correct 4 ms 9300 KB Output is correct
15 Correct 5 ms 9300 KB Output is correct
16 Correct 4 ms 9300 KB Output is correct
17 Correct 4 ms 9284 KB Output is correct
18 Correct 4 ms 9300 KB Output is correct
19 Correct 5 ms 9336 KB Output is correct
20 Correct 4 ms 9428 KB Output is correct
21 Correct 4 ms 9428 KB Output is correct
22 Correct 4 ms 9416 KB Output is correct
23 Correct 5 ms 9428 KB Output is correct
24 Correct 6 ms 9428 KB Output is correct
25 Correct 6 ms 9428 KB Output is correct
26 Correct 6 ms 9300 KB Output is correct
27 Correct 6 ms 9300 KB Output is correct
28 Correct 6 ms 9428 KB Output is correct
29 Correct 5 ms 9300 KB Output is correct
30 Correct 5 ms 9428 KB Output is correct
31 Correct 5 ms 9300 KB Output is correct
32 Correct 5 ms 9412 KB Output is correct
33 Correct 5 ms 9428 KB Output is correct
34 Correct 5 ms 9428 KB Output is correct
35 Correct 5 ms 9404 KB Output is correct
36 Correct 6 ms 9420 KB Output is correct
37 Correct 5 ms 9396 KB Output is correct
38 Correct 5 ms 9428 KB Output is correct
39 Correct 5 ms 9420 KB Output is correct
40 Correct 5 ms 9428 KB Output is correct
41 Correct 5 ms 9428 KB Output is correct
42 Correct 5 ms 9428 KB Output is correct
43 Correct 5 ms 9428 KB Output is correct
44 Correct 7 ms 9420 KB Output is correct
45 Correct 6 ms 9428 KB Output is correct
46 Correct 6 ms 9300 KB Output is correct
47 Correct 5 ms 9380 KB Output is correct
48 Correct 6 ms 9428 KB Output is correct
49 Correct 6 ms 9428 KB Output is correct
50 Correct 5 ms 9428 KB Output is correct
51 Correct 5 ms 9416 KB Output is correct
52 Correct 6 ms 9416 KB Output is correct
53 Correct 5 ms 9416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9300 KB Output is correct
2 Correct 4 ms 9284 KB Output is correct
3 Correct 4 ms 9300 KB Output is correct
4 Correct 5 ms 9300 KB Output is correct
5 Correct 4 ms 9300 KB Output is correct
6 Correct 4 ms 9300 KB Output is correct
7 Correct 5 ms 9300 KB Output is correct
8 Correct 4 ms 9300 KB Output is correct
9 Correct 5 ms 9300 KB Output is correct
10 Correct 5 ms 9300 KB Output is correct
11 Correct 5 ms 9288 KB Output is correct
12 Correct 4 ms 9300 KB Output is correct
13 Correct 4 ms 9300 KB Output is correct
14 Correct 4 ms 9300 KB Output is correct
15 Correct 5 ms 9300 KB Output is correct
16 Correct 4 ms 9300 KB Output is correct
17 Correct 4 ms 9284 KB Output is correct
18 Correct 4 ms 9300 KB Output is correct
19 Correct 5 ms 9336 KB Output is correct
20 Correct 4 ms 9428 KB Output is correct
21 Correct 4 ms 9428 KB Output is correct
22 Correct 4 ms 9416 KB Output is correct
23 Correct 5 ms 9428 KB Output is correct
24 Correct 6 ms 9428 KB Output is correct
25 Correct 6 ms 9428 KB Output is correct
26 Correct 6 ms 9300 KB Output is correct
27 Correct 6 ms 9300 KB Output is correct
28 Correct 6 ms 9428 KB Output is correct
29 Correct 5 ms 9300 KB Output is correct
30 Correct 5 ms 9428 KB Output is correct
31 Correct 5 ms 9300 KB Output is correct
32 Correct 5 ms 9412 KB Output is correct
33 Correct 5 ms 9428 KB Output is correct
34 Correct 5 ms 9428 KB Output is correct
35 Correct 5 ms 9404 KB Output is correct
36 Correct 6 ms 9420 KB Output is correct
37 Correct 5 ms 9396 KB Output is correct
38 Correct 5 ms 9428 KB Output is correct
39 Correct 5 ms 9420 KB Output is correct
40 Correct 5 ms 9428 KB Output is correct
41 Correct 5 ms 9428 KB Output is correct
42 Correct 5 ms 9428 KB Output is correct
43 Correct 5 ms 9428 KB Output is correct
44 Correct 7 ms 9420 KB Output is correct
45 Correct 6 ms 9428 KB Output is correct
46 Correct 6 ms 9300 KB Output is correct
47 Correct 5 ms 9380 KB Output is correct
48 Correct 6 ms 9428 KB Output is correct
49 Correct 6 ms 9428 KB Output is correct
50 Correct 5 ms 9428 KB Output is correct
51 Correct 5 ms 9416 KB Output is correct
52 Correct 6 ms 9416 KB Output is correct
53 Correct 5 ms 9416 KB Output is correct
54 Correct 6 ms 9412 KB Output is correct
55 Correct 17 ms 21588 KB Output is correct
56 Correct 6 ms 9556 KB Output is correct
57 Correct 12 ms 17668 KB Output is correct
58 Correct 35 ms 30080 KB Output is correct
59 Correct 259 ms 161040 KB Output is correct
60 Correct 249 ms 161044 KB Output is correct
61 Correct 274 ms 160952 KB Output is correct
62 Correct 5 ms 9428 KB Output is correct
63 Correct 251 ms 160772 KB Output is correct
64 Correct 200 ms 161068 KB Output is correct
65 Correct 208 ms 161204 KB Output is correct
66 Correct 209 ms 161048 KB Output is correct
67 Correct 214 ms 161048 KB Output is correct
68 Correct 199 ms 161048 KB Output is correct
69 Correct 204 ms 161036 KB Output is correct
70 Correct 30 ms 29968 KB Output is correct
71 Correct 28 ms 29976 KB Output is correct
72 Correct 31 ms 30028 KB Output is correct
73 Correct 27 ms 30036 KB Output is correct
74 Correct 28 ms 30040 KB Output is correct
75 Correct 29 ms 29940 KB Output is correct
76 Correct 29 ms 30028 KB Output is correct
77 Correct 27 ms 30028 KB Output is correct
78 Correct 29 ms 29972 KB Output is correct
79 Correct 28 ms 29968 KB Output is correct
80 Correct 27 ms 30028 KB Output is correct
81 Correct 28 ms 30032 KB Output is correct
82 Correct 28 ms 30028 KB Output is correct
83 Correct 28 ms 29968 KB Output is correct
84 Correct 28 ms 29980 KB Output is correct
85 Correct 29 ms 30028 KB Output is correct
86 Correct 28 ms 29976 KB Output is correct
87 Correct 29 ms 29972 KB Output is correct
88 Correct 34 ms 29960 KB Output is correct
89 Correct 28 ms 29968 KB Output is correct
90 Correct 28 ms 29956 KB Output is correct