Submission #332537

# Submission time Handle Problem Language Result Execution time Memory
332537 2020-12-02T20:01:04 Z limabeans Dango Maker (JOI18_dango_maker) C++17
100 / 100
896 ms 147308 KB
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl











const int maxn = 3002;


int n, m;
string g[maxn];


//RGW
bool can[maxn][maxn][4];

vector<pair<int,int>> diag[maxn+maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    cin>>n>>m;
    for (int i=0; i<n; i++) {
	cin>>g[i];
    }

    // mark centers
    for (int i=0; i<n; i++) {
	for (int j=0; j<m; j++) {
	    //vertical
	    if (i>0 && i+1<n) {
		if (g[i-1][j]=='R' && g[i][j]=='G' && g[i+1][j]=='W') {
		    can[i][j][1]=true;
		}
	    }
	    //horizontal
	    if (j>0 && j+1<m) {
		if (g[i][j-1]=='R' && g[i][j]=='G' && g[i][j+1]=='W') {
		    can[i][j][2]=true;
		}
	    }
	}
    }


    
    for (int i=0; i<n; i++) {
	for (int j=0; j<m; j++) {
	    diag[i+j].push_back({i,j});
	}
    }


    int res = 0;


    for (int d=0; d<n+m; d++) {
	int len = diag[d].size();
	vector<vector<int>> dp(len+1, vector<int>(3, 0)); //0: none, 1: vert, 2: horiz
	for (int i=1; i<=len; i++) {
	    int x = diag[d][i-1].first;
	    int y = diag[d][i-1].second;

	    dp[i][0] = max({dp[i-1][0], dp[i-1][1], dp[i-1][2]});

	    for (int op=1; op<=2; op++) {
		if (can[x][y][op]) {
		    dp[i][op] = max({dp[i][op], 1+dp[i-1][0], 1+dp[i-1][op]}); // vert only compatibile with vert along the diagonal
		}
	    }
	}

	res += max({dp[len][0],dp[len][1],dp[len][2]});
    }

    cout<<res<<endl;    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 620 KB Output is correct
6 Correct 1 ms 640 KB Output is correct
7 Correct 1 ms 640 KB Output is correct
8 Correct 1 ms 620 KB Output is correct
9 Correct 1 ms 620 KB Output is correct
10 Correct 1 ms 620 KB Output is correct
11 Correct 1 ms 620 KB Output is correct
12 Correct 1 ms 748 KB Output is correct
13 Correct 1 ms 620 KB Output is correct
14 Correct 1 ms 620 KB Output is correct
15 Correct 1 ms 620 KB Output is correct
16 Correct 1 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 620 KB Output is correct
6 Correct 1 ms 640 KB Output is correct
7 Correct 1 ms 640 KB Output is correct
8 Correct 1 ms 620 KB Output is correct
9 Correct 1 ms 620 KB Output is correct
10 Correct 1 ms 620 KB Output is correct
11 Correct 1 ms 620 KB Output is correct
12 Correct 1 ms 748 KB Output is correct
13 Correct 1 ms 620 KB Output is correct
14 Correct 1 ms 620 KB Output is correct
15 Correct 1 ms 620 KB Output is correct
16 Correct 1 ms 620 KB Output is correct
17 Correct 1 ms 620 KB Output is correct
18 Correct 1 ms 620 KB Output is correct
19 Correct 1 ms 620 KB Output is correct
20 Correct 1 ms 620 KB Output is correct
21 Correct 1 ms 620 KB Output is correct
22 Correct 3 ms 620 KB Output is correct
23 Correct 1 ms 620 KB Output is correct
24 Correct 1 ms 640 KB Output is correct
25 Correct 1 ms 620 KB Output is correct
26 Correct 1 ms 620 KB Output is correct
27 Correct 1 ms 620 KB Output is correct
28 Correct 1 ms 620 KB Output is correct
29 Correct 1 ms 748 KB Output is correct
30 Correct 1 ms 620 KB Output is correct
31 Correct 1 ms 620 KB Output is correct
32 Correct 1 ms 620 KB Output is correct
33 Correct 1 ms 620 KB Output is correct
34 Correct 1 ms 620 KB Output is correct
35 Correct 1 ms 640 KB Output is correct
36 Correct 1 ms 620 KB Output is correct
37 Correct 1 ms 620 KB Output is correct
38 Correct 1 ms 620 KB Output is correct
39 Correct 1 ms 620 KB Output is correct
40 Correct 1 ms 620 KB Output is correct
41 Correct 1 ms 640 KB Output is correct
42 Correct 1 ms 640 KB Output is correct
43 Correct 1 ms 620 KB Output is correct
44 Correct 1 ms 620 KB Output is correct
45 Correct 1 ms 620 KB Output is correct
46 Correct 1 ms 620 KB Output is correct
47 Correct 14 ms 620 KB Output is correct
48 Correct 1 ms 620 KB Output is correct
49 Correct 1 ms 620 KB Output is correct
50 Correct 1 ms 620 KB Output is correct
51 Correct 1 ms 620 KB Output is correct
52 Correct 1 ms 620 KB Output is correct
53 Correct 1 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 620 KB Output is correct
2 Correct 1 ms 620 KB Output is correct
3 Correct 1 ms 620 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
5 Correct 1 ms 620 KB Output is correct
6 Correct 1 ms 640 KB Output is correct
7 Correct 1 ms 640 KB Output is correct
8 Correct 1 ms 620 KB Output is correct
9 Correct 1 ms 620 KB Output is correct
10 Correct 1 ms 620 KB Output is correct
11 Correct 1 ms 620 KB Output is correct
12 Correct 1 ms 748 KB Output is correct
13 Correct 1 ms 620 KB Output is correct
14 Correct 1 ms 620 KB Output is correct
15 Correct 1 ms 620 KB Output is correct
16 Correct 1 ms 620 KB Output is correct
17 Correct 1 ms 620 KB Output is correct
18 Correct 1 ms 620 KB Output is correct
19 Correct 1 ms 620 KB Output is correct
20 Correct 1 ms 620 KB Output is correct
21 Correct 1 ms 620 KB Output is correct
22 Correct 3 ms 620 KB Output is correct
23 Correct 1 ms 620 KB Output is correct
24 Correct 1 ms 640 KB Output is correct
25 Correct 1 ms 620 KB Output is correct
26 Correct 1 ms 620 KB Output is correct
27 Correct 1 ms 620 KB Output is correct
28 Correct 1 ms 620 KB Output is correct
29 Correct 1 ms 748 KB Output is correct
30 Correct 1 ms 620 KB Output is correct
31 Correct 1 ms 620 KB Output is correct
32 Correct 1 ms 620 KB Output is correct
33 Correct 1 ms 620 KB Output is correct
34 Correct 1 ms 620 KB Output is correct
35 Correct 1 ms 640 KB Output is correct
36 Correct 1 ms 620 KB Output is correct
37 Correct 1 ms 620 KB Output is correct
38 Correct 1 ms 620 KB Output is correct
39 Correct 1 ms 620 KB Output is correct
40 Correct 1 ms 620 KB Output is correct
41 Correct 1 ms 640 KB Output is correct
42 Correct 1 ms 640 KB Output is correct
43 Correct 1 ms 620 KB Output is correct
44 Correct 1 ms 620 KB Output is correct
45 Correct 1 ms 620 KB Output is correct
46 Correct 1 ms 620 KB Output is correct
47 Correct 14 ms 620 KB Output is correct
48 Correct 1 ms 620 KB Output is correct
49 Correct 1 ms 620 KB Output is correct
50 Correct 1 ms 620 KB Output is correct
51 Correct 1 ms 620 KB Output is correct
52 Correct 1 ms 620 KB Output is correct
53 Correct 1 ms 620 KB Output is correct
54 Correct 1 ms 748 KB Output is correct
55 Correct 3 ms 1132 KB Output is correct
56 Correct 2 ms 876 KB Output is correct
57 Correct 6 ms 7788 KB Output is correct
58 Correct 97 ms 21100 KB Output is correct
59 Correct 896 ms 147196 KB Output is correct
60 Correct 883 ms 147180 KB Output is correct
61 Correct 880 ms 147308 KB Output is correct
62 Correct 1 ms 748 KB Output is correct
63 Correct 850 ms 143596 KB Output is correct
64 Correct 786 ms 147180 KB Output is correct
65 Correct 797 ms 147308 KB Output is correct
66 Correct 787 ms 147308 KB Output is correct
67 Correct 768 ms 127852 KB Output is correct
68 Correct 761 ms 127980 KB Output is correct
69 Correct 797 ms 133356 KB Output is correct
70 Correct 81 ms 21132 KB Output is correct
71 Correct 84 ms 21228 KB Output is correct
72 Correct 82 ms 21228 KB Output is correct
73 Correct 83 ms 21228 KB Output is correct
74 Correct 83 ms 21228 KB Output is correct
75 Correct 84 ms 21356 KB Output is correct
76 Correct 83 ms 21228 KB Output is correct
77 Correct 81 ms 21228 KB Output is correct
78 Correct 83 ms 21228 KB Output is correct
79 Correct 81 ms 21228 KB Output is correct
80 Correct 81 ms 21228 KB Output is correct
81 Correct 81 ms 21228 KB Output is correct
82 Correct 82 ms 21356 KB Output is correct
83 Correct 82 ms 21228 KB Output is correct
84 Correct 88 ms 21228 KB Output is correct
85 Correct 81 ms 21228 KB Output is correct
86 Correct 82 ms 21228 KB Output is correct
87 Correct 88 ms 21356 KB Output is correct
88 Correct 84 ms 21228 KB Output is correct
89 Correct 81 ms 21228 KB Output is correct
90 Correct 83 ms 21228 KB Output is correct