Submission #251187

# Submission time Handle Problem Language Result Execution time Memory
251187 2020-07-20T13:50:10 Z mat_v Dango Maker (JOI18_dango_maker) C++14
100 / 100
301 ms 62200 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



int n,m;
int mat[3005][3005];
bool moze[3005][3005][2];
int dp[3005][3];

pii kurac[6005];

int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    ff(i,1,n){
        string x;
        cin >> x;
        ff(j,0,m - 1){
            if(x[j] == 'R')mat[i][j + 1] = 0;
            else if(x[j] == 'G')mat[i][j + 1] = 1;
            else if(x[j] == 'W')mat[i][j + 1] = 2;
        }
    }
    ff(i,1,6000)kurac[i] = {1e9,0};
    ff(i,1,n){
        ff(j,1,m){
            kurac[i + j].xx = min(kurac[i + j].xx, j);
            kurac[i + j].yy = max(kurac[i + j].yy, j);
        }
    }
    ff(i,1,n){
        ff(j,1,m){
            if(mat[i][j] != 1)continue;
            if(mat[i][j - 1] == 0 && mat[i][j + 1] == 2 && j > 1 ){
                moze[i][j][0] = 1;
            }
            if(mat[i - 1][j] == 0 && mat[i + 1][j] == 2 && i > 1){
                moze[i][j][1] = 1;
            }
        }
    }
    int res = 0;
    ff(s,2,n + m){
        ff(i,1,m)dp[i][0] = dp[i][1] = dp[i][2] = 0;
        int l = kurac[s].xx;
        int r = kurac[s].yy;

        dp[l][0] = 0;
        if(moze[s - l][l][0])dp[l][1] = 1;
        else dp[l][1] = -1e9;
        if(moze[s - l][l][1])dp[l][2] = 1;
        else dp[l][2] = -1e9;
        ff(j,l + 1,r){
            dp[j][0] = max(dp[j - 1][0], max(dp[j - 1][1], dp[j - 1][2]));
            dp[j][0] = max(dp[j][0], 0);
            dp[j][1] = dp[j][2] = -1e9;
            if(moze[s - j][j][0])dp[j][1] = max(dp[j - 1][0], dp[j - 1][1]) + 1;
            if(moze[s - j][j][1])dp[j][2] = max(dp[j - 1][0], dp[j - 1][2]) + 1;
        }
        res += max(dp[r][0], max(dp[r][1], dp[r][2]));
    }
    cout << res << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 404 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 0 ms 512 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 512 KB Output is correct
34 Correct 1 ms 512 KB Output is correct
35 Correct 0 ms 512 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 0 ms 512 KB Output is correct
38 Correct 1 ms 512 KB Output is correct
39 Correct 0 ms 512 KB Output is correct
40 Correct 1 ms 512 KB Output is correct
41 Correct 1 ms 512 KB Output is correct
42 Correct 1 ms 512 KB Output is correct
43 Correct 0 ms 512 KB Output is correct
44 Correct 1 ms 512 KB Output is correct
45 Correct 0 ms 512 KB Output is correct
46 Correct 1 ms 512 KB Output is correct
47 Correct 1 ms 512 KB Output is correct
48 Correct 0 ms 512 KB Output is correct
49 Correct 0 ms 512 KB Output is correct
50 Correct 1 ms 512 KB Output is correct
51 Correct 1 ms 512 KB Output is correct
52 Correct 1 ms 640 KB Output is correct
53 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 404 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 0 ms 512 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 512 KB Output is correct
34 Correct 1 ms 512 KB Output is correct
35 Correct 0 ms 512 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 0 ms 512 KB Output is correct
38 Correct 1 ms 512 KB Output is correct
39 Correct 0 ms 512 KB Output is correct
40 Correct 1 ms 512 KB Output is correct
41 Correct 1 ms 512 KB Output is correct
42 Correct 1 ms 512 KB Output is correct
43 Correct 0 ms 512 KB Output is correct
44 Correct 1 ms 512 KB Output is correct
45 Correct 0 ms 512 KB Output is correct
46 Correct 1 ms 512 KB Output is correct
47 Correct 1 ms 512 KB Output is correct
48 Correct 0 ms 512 KB Output is correct
49 Correct 0 ms 512 KB Output is correct
50 Correct 1 ms 512 KB Output is correct
51 Correct 1 ms 512 KB Output is correct
52 Correct 1 ms 640 KB Output is correct
53 Correct 1 ms 512 KB Output is correct
54 Correct 11 ms 512 KB Output is correct
55 Correct 8 ms 12928 KB Output is correct
56 Correct 13 ms 512 KB Output is correct
57 Correct 8 ms 15488 KB Output is correct
58 Correct 38 ms 15180 KB Output is correct
59 Correct 299 ms 62200 KB Output is correct
60 Correct 301 ms 62200 KB Output is correct
61 Correct 294 ms 62200 KB Output is correct
62 Correct 11 ms 416 KB Output is correct
63 Correct 284 ms 62060 KB Output is correct
64 Correct 170 ms 62200 KB Output is correct
65 Correct 173 ms 62200 KB Output is correct
66 Correct 182 ms 62200 KB Output is correct
67 Correct 166 ms 54392 KB Output is correct
68 Correct 171 ms 54540 KB Output is correct
69 Correct 181 ms 58360 KB Output is correct
70 Correct 23 ms 15232 KB Output is correct
71 Correct 22 ms 15224 KB Output is correct
72 Correct 22 ms 15232 KB Output is correct
73 Correct 23 ms 15232 KB Output is correct
74 Correct 25 ms 15232 KB Output is correct
75 Correct 23 ms 15232 KB Output is correct
76 Correct 24 ms 15232 KB Output is correct
77 Correct 24 ms 15232 KB Output is correct
78 Correct 24 ms 15232 KB Output is correct
79 Correct 23 ms 15232 KB Output is correct
80 Correct 26 ms 15232 KB Output is correct
81 Correct 24 ms 15352 KB Output is correct
82 Correct 24 ms 15232 KB Output is correct
83 Correct 23 ms 15232 KB Output is correct
84 Correct 25 ms 15232 KB Output is correct
85 Correct 22 ms 15232 KB Output is correct
86 Correct 24 ms 15232 KB Output is correct
87 Correct 27 ms 15232 KB Output is correct
88 Correct 23 ms 15232 KB Output is correct
89 Correct 23 ms 15232 KB Output is correct
90 Correct 21 ms 15232 KB Output is correct