Submission #254744

# Submission time Handle Problem Language Result Execution time Memory
254744 2020-07-30T14:06:27 Z egekabas Dango Maker (JOI18_dango_maker) C++14
100 / 100
363 ms 39416 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
int n, m;
int a[3009][3009];
int cl(int x, int y){
    return(x >= 0 && y >= 0 && a[x][y] == 1 && a[x][y+1] == 2 && a[x][y+2] == 3);
}
int cd(int x, int y){
    return(x >= 0 && y >= 0 && a[x][y] == 1 && a[x+1][y] == 2 && a[x+2][y] == 3);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n >> m;
    string s;
    for(int i = 0; i < n; ++i){
        cin >> s;
        for(int j = 0; j < m; ++j){
            if(s[j] == 'R')
                a[i][j] = 1;
            else if(s[j] == 'G')
                a[i][j] = 2;
            else
                a[i][j] = 3;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < m; ++j){
            if(a[i][j] != 2) continue;
            vector<pii> v;
            for(int red = 0; i+red < n && red <= j; ++red){
                if(a[i+red][j-red] != 2) break;
                v.pb({(i+red), (j-red)});
            }
            vector<pii> dp(v.size()+5);
            for(int i = v.size()-1; i >= 0; --i){
                dp[i].ff = max(dp[i+1].ff, dp[i+2].ss)+cl(v[i].ff, v[i].ss-1);
                dp[i].ss = max(dp[i+1].ss, dp[i+2].ff)+cd(v[i].ff-1, v[i].ss);
            }
            ans += max(dp[0].ff, dp[0].ss);
            for(auto u : v)
                a[u.ff][u.ss] = 0;
        }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 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 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 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 0 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 0 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 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 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 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 0 ms 384 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 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 0 ms 384 KB Output is correct
39 Correct 0 ms 384 KB Output is correct
40 Correct 0 ms 384 KB Output is correct
41 Correct 1 ms 384 KB Output is correct
42 Correct 1 ms 384 KB Output is correct
43 Correct 0 ms 384 KB Output is correct
44 Correct 0 ms 384 KB Output is correct
45 Correct 0 ms 384 KB Output is correct
46 Correct 0 ms 384 KB Output is correct
47 Correct 0 ms 384 KB Output is correct
48 Correct 0 ms 384 KB Output is correct
49 Correct 0 ms 384 KB Output is correct
50 Correct 1 ms 384 KB Output is correct
51 Correct 0 ms 384 KB Output is correct
52 Correct 1 ms 384 KB Output is correct
53 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 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 0 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 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 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 0 ms 384 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 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
29 Correct 1 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 1 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 0 ms 384 KB Output is correct
39 Correct 0 ms 384 KB Output is correct
40 Correct 0 ms 384 KB Output is correct
41 Correct 1 ms 384 KB Output is correct
42 Correct 1 ms 384 KB Output is correct
43 Correct 0 ms 384 KB Output is correct
44 Correct 0 ms 384 KB Output is correct
45 Correct 0 ms 384 KB Output is correct
46 Correct 0 ms 384 KB Output is correct
47 Correct 0 ms 384 KB Output is correct
48 Correct 0 ms 384 KB Output is correct
49 Correct 0 ms 384 KB Output is correct
50 Correct 1 ms 384 KB Output is correct
51 Correct 0 ms 384 KB Output is correct
52 Correct 1 ms 384 KB Output is correct
53 Correct 0 ms 384 KB Output is correct
54 Correct 1 ms 384 KB Output is correct
55 Correct 7 ms 12416 KB Output is correct
56 Correct 1 ms 384 KB Output is correct
57 Correct 5 ms 8448 KB Output is correct
58 Correct 41 ms 9216 KB Output is correct
59 Correct 362 ms 39288 KB Output is correct
60 Correct 363 ms 39304 KB Output is correct
61 Correct 354 ms 39288 KB Output is correct
62 Correct 1 ms 384 KB Output is correct
63 Correct 345 ms 39416 KB Output is correct
64 Correct 149 ms 39288 KB Output is correct
65 Correct 146 ms 39288 KB Output is correct
66 Correct 169 ms 39416 KB Output is correct
67 Correct 253 ms 39288 KB Output is correct
68 Correct 267 ms 39416 KB Output is correct
69 Correct 277 ms 39288 KB Output is correct
70 Correct 16 ms 9216 KB Output is correct
71 Correct 19 ms 9220 KB Output is correct
72 Correct 19 ms 9216 KB Output is correct
73 Correct 17 ms 9216 KB Output is correct
74 Correct 17 ms 9216 KB Output is correct
75 Correct 17 ms 9216 KB Output is correct
76 Correct 17 ms 9216 KB Output is correct
77 Correct 16 ms 9216 KB Output is correct
78 Correct 17 ms 9216 KB Output is correct
79 Correct 17 ms 9216 KB Output is correct
80 Correct 18 ms 9216 KB Output is correct
81 Correct 17 ms 9216 KB Output is correct
82 Correct 20 ms 9216 KB Output is correct
83 Correct 17 ms 9216 KB Output is correct
84 Correct 17 ms 9216 KB Output is correct
85 Correct 17 ms 9216 KB Output is correct
86 Correct 17 ms 9216 KB Output is correct
87 Correct 17 ms 9216 KB Output is correct
88 Correct 19 ms 9216 KB Output is correct
89 Correct 19 ms 9216 KB Output is correct
90 Correct 20 ms 9216 KB Output is correct