Submission #717972

# Submission time Handle Problem Language Result Execution time Memory
717972 2023-04-03T01:27:57 Z YeoBL Dango Maker (JOI18_dango_maker) C++14
100 / 100
289 ms 35668 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m, tmp, tot = 0; cin >> n >> m;
	char ch[n][m];
	bool h[n][m], v[n][m];
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			h[i][j] = v[i][j] = 0;
			cin >> ch[i][j];
		}
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			if (ch[i][j] != 'G') continue;
			if (i != 0 and i != n - 1 and ch[i - 1][j] == 'R' and ch[i + 1][j] == 'W') v[i][j] = 1;
			if (j != 0 and j != m - 1 and ch[i][j - 1] == 'R' and ch[i][j + 1] == 'W') h[i][j] = 1;
		}
	}
	/*for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cerr << v[i][j];
		}
		cerr << '\n';
	}
	cerr << "HORI\n";
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cerr << h[i][j];
		}
		cerr << '\n';
	}*/
	for (int diag = 0; diag < n + m - 1; diag++){
		int dp[n][2]; tmp = 0;
		bool flag = 0;
		for (int x = 0; x < n; x++){
			int y = diag - x;
			if (y < 0) break;
			if (y >= m) continue;
			if (flag){
				dp[x][0] = max(dp[x - 1][1], dp[x - 1][0] + h[x][y]);
				dp[x][1] = max(dp[x - 1][1] + v[x][y], dp[x - 1][0]);
			}
			else{
				if (h[x][y]) dp[x][0] = 1;
				else dp[x][0] = 0;
				if (v[x][y]) dp[x][1] = 1;
				else dp[x][1] = 0;
			}
			flag = 1;
			//if (diag == 6) cerr << "BOTH: " << dp[x][0] << ' ' << dp[x][1] << '\n';
			tmp = max(tmp, max(dp[x][0], dp[x][1]));
		}
		//cerr << diag << ' ' << tmp << '\n';
		tot += tmp;
	}
	cout << tot;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 320 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 320 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 320 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 324 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 320 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 320 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 316 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 320 KB Output is correct
43 Correct 1 ms 320 KB Output is correct
44 Correct 1 ms 324 KB Output is correct
45 Correct 0 ms 320 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 0 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 320 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 320 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 320 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 324 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 320 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 320 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 316 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 320 KB Output is correct
43 Correct 1 ms 320 KB Output is correct
44 Correct 1 ms 324 KB Output is correct
45 Correct 0 ms 320 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 0 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 320 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 5 ms 324 KB Output is correct
56 Correct 1 ms 340 KB Output is correct
57 Correct 2 ms 340 KB Output is correct
58 Correct 26 ms 4136 KB Output is correct
59 Correct 289 ms 35668 KB Output is correct
60 Correct 273 ms 35576 KB Output is correct
61 Correct 276 ms 35540 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 272 ms 34408 KB Output is correct
64 Correct 231 ms 35580 KB Output is correct
65 Correct 235 ms 35536 KB Output is correct
66 Correct 232 ms 35576 KB Output is correct
67 Correct 225 ms 35656 KB Output is correct
68 Correct 230 ms 35528 KB Output is correct
69 Correct 230 ms 35536 KB Output is correct
70 Correct 21 ms 4136 KB Output is correct
71 Correct 21 ms 4224 KB Output is correct
72 Correct 22 ms 4228 KB Output is correct
73 Correct 21 ms 4160 KB Output is correct
74 Correct 22 ms 4300 KB Output is correct
75 Correct 20 ms 4120 KB Output is correct
76 Correct 21 ms 4132 KB Output is correct
77 Correct 21 ms 4128 KB Output is correct
78 Correct 21 ms 4132 KB Output is correct
79 Correct 20 ms 4180 KB Output is correct
80 Correct 21 ms 4180 KB Output is correct
81 Correct 21 ms 4220 KB Output is correct
82 Correct 22 ms 4180 KB Output is correct
83 Correct 20 ms 4136 KB Output is correct
84 Correct 22 ms 4228 KB Output is correct
85 Correct 21 ms 4180 KB Output is correct
86 Correct 24 ms 4136 KB Output is correct
87 Correct 21 ms 4180 KB Output is correct
88 Correct 21 ms 4212 KB Output is correct
89 Correct 21 ms 4180 KB Output is correct
90 Correct 21 ms 4208 KB Output is correct