Submission #441241

# Submission time Handle Problem Language Result Execution time Memory
441241 2021-07-04T18:17:15 Z ritul_kr_singh Dango Maker (JOI18_dango_maker) C++17
100 / 100
923 ms 11588 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << ' ' <<
#define nl << '\n'
 
const int MAXN = 3e3;
 
int n, m, dp[3][3];
string g[MAXN+1];
 
bool up(int i, int j){
	return i > 2 && g[i-2][j] == 'R' && g[i-1][j] == 'G' && g[i][j] == 'W';
}
 
bool left(int i, int j){
	return j > 2 && g[i][j-2] == 'R' && g[i][j-1] == 'G' && g[i][j] == 'W';
}
 
signed main(){
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	for(int i=1; i<=n; ++i) cin >> g[i], g[i] = ' ' + g[i];
 
	for(int s=2; s<=n+m; ++s){
		int i = max(1LL, s - m);
		for(; i<=n && s-i; ++i){
			int j = s - i, cur[3][3];
 
			for(int a=0; a<3; ++a)
				cur[a][0] = cur[a][1] = cur[a][2] = 0;
 
			for(int a=0; a<3; ++a){
				for(int b=0; b<3; ++b){
					for(int c=0; c<3; ++c){
						if(a == 1 && max(b, c) > a) continue;
						if(a == 1 && !up(i, j)) continue;
						if(a == 2 && !left(i, j)) continue;
						cur[a][b] = max(cur[a][b], bool(a) + dp[b][c]);
					}
				}
			}
			swap(dp, cur);
		}		
		for(int a=0; a<3; ++a)
			for(int b=0; b<3; ++b)
				dp[0][0] = max(dp[0][0], dp[a][b]);
		for(int a=0; a<3; ++a)
			for(int b=0; b<3; ++b)
				dp[a][b] = dp[0][0];
	}
	cout << dp[0][0];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 436 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 436 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 408 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 0 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 1 ms 404 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 0 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 436 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 408 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 0 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 1 ms 404 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 0 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 2 ms 332 KB Output is correct
56 Correct 2 ms 332 KB Output is correct
57 Correct 2 ms 332 KB Output is correct
58 Correct 93 ms 2408 KB Output is correct
59 Correct 923 ms 11484 KB Output is correct
60 Correct 903 ms 11488 KB Output is correct
61 Correct 896 ms 11488 KB Output is correct
62 Correct 2 ms 332 KB Output is correct
63 Correct 843 ms 11160 KB Output is correct
64 Correct 774 ms 11480 KB Output is correct
65 Correct 775 ms 11480 KB Output is correct
66 Correct 784 ms 11480 KB Output is correct
67 Correct 832 ms 11484 KB Output is correct
68 Correct 841 ms 11588 KB Output is correct
69 Correct 852 ms 11488 KB Output is correct
70 Correct 78 ms 2380 KB Output is correct
71 Correct 79 ms 2380 KB Output is correct
72 Correct 79 ms 2420 KB Output is correct
73 Correct 79 ms 2380 KB Output is correct
74 Correct 80 ms 2380 KB Output is correct
75 Correct 79 ms 2380 KB Output is correct
76 Correct 79 ms 2380 KB Output is correct
77 Correct 79 ms 2380 KB Output is correct
78 Correct 82 ms 2380 KB Output is correct
79 Correct 79 ms 2380 KB Output is correct
80 Correct 79 ms 2404 KB Output is correct
81 Correct 80 ms 2380 KB Output is correct
82 Correct 80 ms 2380 KB Output is correct
83 Correct 79 ms 2340 KB Output is correct
84 Correct 77 ms 2340 KB Output is correct
85 Correct 82 ms 2380 KB Output is correct
86 Correct 78 ms 2380 KB Output is correct
87 Correct 79 ms 2400 KB Output is correct
88 Correct 82 ms 2336 KB Output is correct
89 Correct 78 ms 2400 KB Output is correct
90 Correct 78 ms 2380 KB Output is correct