Submission #132817

# Submission time Handle Problem Language Result Execution time Memory
132817 2019-07-19T16:35:13 Z Gustav Dango Maker (JOI18_dango_maker) C++14
100 / 100
1363 ms 44888 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
const int inf = 0x3f3f3f3f;
const ll linf = 123456789012345678;
const ll mod = 998244353;
#pragma GCC optimize("Ofast")
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl

int n, m;
vvi a;

int main(){
    cin >> n >> m;
    a = vvi(n, vi(m));
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        for(int j = 0; j < m; j++){
            if(s[j] == 'G') a[i][j] = 1;
            else if(s[j] == 'W') a[i][j] = 2;
        }
    }

    int ans = 0;
    for(int k = 0; k < n+m-1; k++){
        int c = k;
        int r = 0;
        if(c >= m){
            r = c-m+1;
            c = m-1;
        }
        vvi dp(min(c+1,n-r)+1, vi(3));
        int pos = min(c,n-r-1);
        while(r < n && c >= 0){
            dp[pos][0] = dp[pos+1][0];
            dp[pos][1] = dp[pos+1][0];
            dp[pos][2] = dp[pos+1][1];
            if(c + 2 < m && a[r][c] == 0 && a[r][c+1] == 1 && a[r][c+2] == 2){
                dp[pos][0] = max(dp[pos][0], dp[pos+1][2] + 1);
                dp[pos][1] = max(dp[pos][1], dp[pos+1][2] + 1);
                dp[pos][2] = max(dp[pos][2], dp[pos+1][2] + 1);
            }
            if(r + 2 < n && a[r][c] == 0 && a[r+1][c] == 1 && a[r+2][c] == 2){
                dp[pos][0] = max(dp[pos][0], dp[pos+1][0] + 1);
            }
            r++;
            c--;
            pos--;
        }
        ans += dp[0][0];
    }
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 360 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 360 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 3 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Correct 2 ms 504 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 0 ms 376 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 2 ms 256 KB Output is correct
34 Correct 3 ms 252 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 256 KB Output is correct
37 Correct 3 ms 376 KB Output is correct
38 Correct 2 ms 256 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 256 KB Output is correct
41 Correct 2 ms 256 KB Output is correct
42 Correct 2 ms 256 KB Output is correct
43 Correct 2 ms 256 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 256 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 256 KB Output is correct
50 Correct 4 ms 376 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 2 ms 376 KB Output is correct
53 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 256 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 360 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 3 ms 256 KB Output is correct
18 Correct 2 ms 256 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 256 KB Output is correct
25 Correct 2 ms 256 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 256 KB Output is correct
28 Correct 2 ms 504 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 0 ms 376 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
33 Correct 2 ms 256 KB Output is correct
34 Correct 3 ms 252 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 256 KB Output is correct
37 Correct 3 ms 376 KB Output is correct
38 Correct 2 ms 256 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 256 KB Output is correct
41 Correct 2 ms 256 KB Output is correct
42 Correct 2 ms 256 KB Output is correct
43 Correct 2 ms 256 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 256 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 256 KB Output is correct
50 Correct 4 ms 376 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 2 ms 376 KB Output is correct
53 Correct 2 ms 376 KB Output is correct
54 Correct 3 ms 376 KB Output is correct
55 Correct 7 ms 504 KB Output is correct
56 Correct 8 ms 376 KB Output is correct
57 Correct 5 ms 504 KB Output is correct
58 Correct 149 ms 5240 KB Output is correct
59 Correct 1347 ms 44796 KB Output is correct
60 Correct 1363 ms 44876 KB Output is correct
61 Correct 1345 ms 44852 KB Output is correct
62 Correct 3 ms 376 KB Output is correct
63 Correct 1312 ms 43376 KB Output is correct
64 Correct 1211 ms 44888 KB Output is correct
65 Correct 1199 ms 44744 KB Output is correct
66 Correct 1199 ms 44884 KB Output is correct
67 Correct 1221 ms 44824 KB Output is correct
68 Correct 1212 ms 44680 KB Output is correct
69 Correct 1211 ms 44712 KB Output is correct
70 Correct 133 ms 5368 KB Output is correct
71 Correct 132 ms 5240 KB Output is correct
72 Correct 137 ms 5368 KB Output is correct
73 Correct 133 ms 5236 KB Output is correct
74 Correct 133 ms 5240 KB Output is correct
75 Correct 133 ms 5224 KB Output is correct
76 Correct 133 ms 5368 KB Output is correct
77 Correct 134 ms 5328 KB Output is correct
78 Correct 134 ms 5424 KB Output is correct
79 Correct 133 ms 5212 KB Output is correct
80 Correct 134 ms 5240 KB Output is correct
81 Correct 137 ms 5240 KB Output is correct
82 Correct 135 ms 5360 KB Output is correct
83 Correct 133 ms 5240 KB Output is correct
84 Correct 135 ms 5324 KB Output is correct
85 Correct 135 ms 5400 KB Output is correct
86 Correct 133 ms 5228 KB Output is correct
87 Correct 135 ms 5288 KB Output is correct
88 Correct 134 ms 5396 KB Output is correct
89 Correct 136 ms 5468 KB Output is correct
90 Correct 133 ms 5304 KB Output is correct