Submission #207379

# Submission time Handle Problem Language Result Execution time Memory
207379 2020-03-07T11:58:53 Z Saboon Dango Maker (JOI18_dango_maker) C++14
100 / 100
161 ms 89696 KB
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
 
const int maxn = 3000 + 10;
const int inf = 1e9;
 
string s[maxn];
int dp[maxn][maxn][2];

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	int answer = 0;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			if (s[i][j] != 'G')
				continue;
			int can = 0;
			if (i > 0 and i < n - 1 and s[i - 1][j] == 'R' and s[i + 1][j] == 'W')
				can |= 1;
			if (j > 0 and j < m - 1 and s[i][j - 1] == 'R' and s[i][j + 1] == 'W')
				can |= 2;
			if (i > 0 and j < m - 1)
				dp[i][j][0] = dp[i][j][1] = max(dp[i-1][j+1][0], dp[i-1][j+1][1]);
			if (can & 1){
				int t = ((i > 0 and j < m - 1) ? dp[i-1][j+1][0] : 0);
				dp[i][j][0] = max(dp[i][j][0], t + 1);
			}
			if (can & 2){
				int t = ((i > 0 and j < m - 1) ? dp[i-1][j+1][1] : 0);
				dp[i][j][1] = max(dp[i][j][1], t + 1);
			}
			if (i == n - 1 or j == 0 or s[i+1][j-1] != 'G')
				answer += max(dp[i][j][0], dp[i][j][1]);
		}
	}
	cout << answer << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 504 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 504 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 504 KB Output is correct
18 Correct 5 ms 504 KB Output is correct
19 Correct 5 ms 504 KB Output is correct
20 Correct 5 ms 504 KB Output is correct
21 Correct 5 ms 504 KB Output is correct
22 Correct 5 ms 504 KB Output is correct
23 Correct 5 ms 504 KB Output is correct
24 Correct 5 ms 504 KB Output is correct
25 Correct 5 ms 504 KB Output is correct
26 Correct 5 ms 504 KB Output is correct
27 Correct 6 ms 504 KB Output is correct
28 Correct 5 ms 508 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 5 ms 504 KB Output is correct
33 Correct 5 ms 504 KB Output is correct
34 Correct 5 ms 504 KB Output is correct
35 Correct 5 ms 504 KB Output is correct
36 Correct 5 ms 504 KB Output is correct
37 Correct 5 ms 504 KB Output is correct
38 Correct 5 ms 504 KB Output is correct
39 Correct 5 ms 504 KB Output is correct
40 Correct 5 ms 504 KB Output is correct
41 Correct 5 ms 504 KB Output is correct
42 Correct 5 ms 504 KB Output is correct
43 Correct 5 ms 504 KB Output is correct
44 Correct 5 ms 504 KB Output is correct
45 Correct 5 ms 504 KB Output is correct
46 Correct 6 ms 504 KB Output is correct
47 Correct 5 ms 504 KB Output is correct
48 Correct 5 ms 504 KB Output is correct
49 Correct 5 ms 504 KB Output is correct
50 Correct 5 ms 504 KB Output is correct
51 Correct 5 ms 504 KB Output is correct
52 Correct 5 ms 504 KB Output is correct
53 Correct 5 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 504 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 504 KB Output is correct
18 Correct 5 ms 504 KB Output is correct
19 Correct 5 ms 504 KB Output is correct
20 Correct 5 ms 504 KB Output is correct
21 Correct 5 ms 504 KB Output is correct
22 Correct 5 ms 504 KB Output is correct
23 Correct 5 ms 504 KB Output is correct
24 Correct 5 ms 504 KB Output is correct
25 Correct 5 ms 504 KB Output is correct
26 Correct 5 ms 504 KB Output is correct
27 Correct 6 ms 504 KB Output is correct
28 Correct 5 ms 508 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 5 ms 376 KB Output is correct
31 Correct 5 ms 376 KB Output is correct
32 Correct 5 ms 504 KB Output is correct
33 Correct 5 ms 504 KB Output is correct
34 Correct 5 ms 504 KB Output is correct
35 Correct 5 ms 504 KB Output is correct
36 Correct 5 ms 504 KB Output is correct
37 Correct 5 ms 504 KB Output is correct
38 Correct 5 ms 504 KB Output is correct
39 Correct 5 ms 504 KB Output is correct
40 Correct 5 ms 504 KB Output is correct
41 Correct 5 ms 504 KB Output is correct
42 Correct 5 ms 504 KB Output is correct
43 Correct 5 ms 504 KB Output is correct
44 Correct 5 ms 504 KB Output is correct
45 Correct 5 ms 504 KB Output is correct
46 Correct 6 ms 504 KB Output is correct
47 Correct 5 ms 504 KB Output is correct
48 Correct 5 ms 504 KB Output is correct
49 Correct 5 ms 504 KB Output is correct
50 Correct 5 ms 504 KB Output is correct
51 Correct 5 ms 504 KB Output is correct
52 Correct 5 ms 504 KB Output is correct
53 Correct 5 ms 504 KB Output is correct
54 Correct 5 ms 504 KB Output is correct
55 Correct 6 ms 1016 KB Output is correct
56 Correct 5 ms 632 KB Output is correct
57 Correct 9 ms 8440 KB Output is correct
58 Correct 24 ms 14200 KB Output is correct
59 Correct 161 ms 89592 KB Output is correct
60 Correct 156 ms 89592 KB Output is correct
61 Correct 158 ms 89696 KB Output is correct
62 Correct 5 ms 504 KB Output is correct
63 Correct 154 ms 88928 KB Output is correct
64 Correct 85 ms 89592 KB Output is correct
65 Correct 86 ms 89592 KB Output is correct
66 Correct 90 ms 89592 KB Output is correct
67 Correct 67 ms 50424 KB Output is correct
68 Correct 79 ms 72824 KB Output is correct
69 Correct 96 ms 89592 KB Output is correct
70 Correct 16 ms 14328 KB Output is correct
71 Correct 17 ms 14304 KB Output is correct
72 Correct 18 ms 14328 KB Output is correct
73 Correct 16 ms 14328 KB Output is correct
74 Correct 15 ms 14328 KB Output is correct
75 Correct 16 ms 14332 KB Output is correct
76 Correct 16 ms 14328 KB Output is correct
77 Correct 16 ms 14328 KB Output is correct
78 Correct 16 ms 14328 KB Output is correct
79 Correct 15 ms 14328 KB Output is correct
80 Correct 15 ms 14328 KB Output is correct
81 Correct 15 ms 14332 KB Output is correct
82 Correct 16 ms 14328 KB Output is correct
83 Correct 15 ms 14328 KB Output is correct
84 Correct 15 ms 14316 KB Output is correct
85 Correct 16 ms 14328 KB Output is correct
86 Correct 16 ms 14332 KB Output is correct
87 Correct 15 ms 14328 KB Output is correct
88 Correct 15 ms 14284 KB Output is correct
89 Correct 16 ms 14328 KB Output is correct
90 Correct 20 ms 14328 KB Output is correct