답안 #680143

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680143 2023-01-10T02:20:38 Z Duy_e Dango Maker (JOI18_dango_maker) C++14
100 / 100
237 ms 9292 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<ll, ll>
#define st first
#define nd second
#define file "test"
#define rep(i, begin, end) for (ll i = (begin); i <= (end); i ++)
#define rrep(i, begin, end) for (ll i = (begin); i >= (end); i --)
using namespace std;
const long long INF = 1e18;
const long long N = 2e5 + 5;

ll dp[N][3], n, m, ans;
char a[3005][3005];

bool check(char a, char b, char c) {
    return a == 'R' && b == 'G' && c == 'W';
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
    #endif
    
    cin >> n >> m;
    rep(i, 1, n) rep(j, 1, m) cin >> a[i][j];

    rep(s, 2, n + m) {
        
        ll res = 0;
        rep(j, 1, m) dp[j][1] = dp[j][2] = 0;

        rep(j, 1, m) {
            int i = s - j;
            if (i < 1 || i > n) continue;

            // 1: vertical
            // 2: horizontal

            { // no dango
                dp[j][1] = max(dp[j - 1][1], dp[j - 1][2]);

                if (j > 3)
                    dp[j][2] = max(dp[j - 1][2], dp[j - 3][1]);
            }

            { // if can make dango
                if (i > 2 && check(a[i - 2][j], a[i - 1][j], a[i][j]))
                    dp[j][1] ++;
                
                if (j > 2 && check(a[i][j - 2], a[i][j - 1], a[i][j]))
                    dp[j][2] ++;
            }
            
            res = max(res, max(dp[j][1], dp[j][2]));
        }
        ans += res;
    }

    cout << ans << '\n';

    return 0;
}    
/**  /\_/\
*   (= ._.)
*   / >🍵 \>🍮

dp on diagonal

**/

Compilation message

dango_maker.cpp:66:9: warning: "/*" within comment [-Wcomment]
   66 | /**  /\_/\
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 424 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 0 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 ms 340 KB Output is correct
40 Correct 0 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 0 ms 340 KB Output is correct
51 Correct 0 ms 340 KB Output is correct
52 Correct 0 ms 340 KB Output is correct
53 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 424 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 0 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 ms 340 KB Output is correct
40 Correct 0 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 0 ms 340 KB Output is correct
51 Correct 0 ms 340 KB Output is correct
52 Correct 0 ms 340 KB Output is correct
53 Correct 0 ms 340 KB Output is correct
54 Correct 15 ms 416 KB Output is correct
55 Correct 5 ms 9044 KB Output is correct
56 Correct 15 ms 424 KB Output is correct
57 Correct 3 ms 6100 KB Output is correct
58 Correct 24 ms 3220 KB Output is correct
59 Correct 237 ms 9192 KB Output is correct
60 Correct 207 ms 9216 KB Output is correct
61 Correct 214 ms 9144 KB Output is correct
62 Correct 14 ms 340 KB Output is correct
63 Correct 215 ms 9164 KB Output is correct
64 Correct 195 ms 9200 KB Output is correct
65 Correct 199 ms 9292 KB Output is correct
66 Correct 188 ms 9148 KB Output is correct
67 Correct 192 ms 9140 KB Output is correct
68 Correct 202 ms 9212 KB Output is correct
69 Correct 192 ms 9120 KB Output is correct
70 Correct 23 ms 3308 KB Output is correct
71 Correct 30 ms 3284 KB Output is correct
72 Correct 23 ms 3312 KB Output is correct
73 Correct 24 ms 3220 KB Output is correct
74 Correct 21 ms 3312 KB Output is correct
75 Correct 21 ms 3312 KB Output is correct
76 Correct 27 ms 3284 KB Output is correct
77 Correct 22 ms 3284 KB Output is correct
78 Correct 22 ms 3224 KB Output is correct
79 Correct 27 ms 3284 KB Output is correct
80 Correct 21 ms 3256 KB Output is correct
81 Correct 22 ms 3276 KB Output is correct
82 Correct 23 ms 3296 KB Output is correct
83 Correct 23 ms 3284 KB Output is correct
84 Correct 22 ms 3264 KB Output is correct
85 Correct 22 ms 3284 KB Output is correct
86 Correct 22 ms 3272 KB Output is correct
87 Correct 30 ms 3284 KB Output is correct
88 Correct 24 ms 3284 KB Output is correct
89 Correct 22 ms 3260 KB Output is correct
90 Correct 22 ms 3300 KB Output is correct