답안 #532720

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
532720 2022-03-03T18:12:48 Z rk42745417 Dango Maker (JOI18_dango_maker) C++17
100 / 100
275 ms 21572 KB
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(0);
using ll = int64_t;
using uint = uint32_t;
using ull = uint64_t;
using ld = long double;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const ll LINF = ll(4e18) + ll(2e15);
static int LamyIsCute = []() {
	EmiliaMyWife
	return 48763;
}();

signed main() {
	int n, m;
	cin >> n >> m;
	vector<string> arr(n);
	for(int i = 0; i < n; i++)
		cin >> arr[i];

	vector<vector<bool>> ver(n, vector<bool>(m)), hor = ver;
	for(int i = 0; i + 2 < n; i++)
		for(int j = 0; j < m; j++)
			if(arr[i][j] == 'R' && arr[i + 1][j] == 'G' && arr[i + 2][j] == 'W')
				ver[i][j] = ver[i + 1][j] = ver[i + 2][j] = true;
	for(int i = 0; i < n; i++)
		for(int j = 0; j + 2 < m; j++)
			if(arr[i][j] == 'R' && arr[i][j + 1] == 'G' && arr[i][j + 2] == 'W')
				hor[i][j] = hor[i][j + 1] = hor[i][j + 2] = true;

	vector<array<int, 3>> dp(n);
	int ans = 0;
	for(int s = 1; s < n + m - 1; s++) {
		fill(dp.begin(), dp.end(), array<int, 3>());
		for(int i = max(0, s - m + 1); i <= min(n - 1, s); i++) {
			int j = s - i;
			if(i)
				dp[i][0] = max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]});
			if(arr[i][j] == 'G' && ver[i][j])
				dp[i][1] = (i ? max(dp[i - 1][0], dp[i - 1][1]) : 0) + 1;
			if(arr[i][j] == 'G' && hor[i][j])
				dp[i][2] = (i ? max(dp[i - 1][0], dp[i - 1][2]) : 0) + 1;
		}
		int x = min(n - 1, s);
		ans += max({dp[x][0], dp[x][1], dp[x][2]});
	}
	cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 308 KB Output is correct
22 Correct 1 ms 304 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 0 ms 312 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 316 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 0 ms 316 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 308 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 0 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 308 KB Output is correct
49 Correct 1 ms 312 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 1 ms 204 KB Output is correct
52 Correct 0 ms 204 KB Output is correct
53 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 312 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 308 KB Output is correct
22 Correct 1 ms 304 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 0 ms 312 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 316 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 0 ms 316 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 308 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 0 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 308 KB Output is correct
49 Correct 1 ms 312 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 1 ms 204 KB Output is correct
52 Correct 0 ms 204 KB Output is correct
53 Correct 0 ms 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 11 ms 828 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 6 ms 712 KB Output is correct
58 Correct 26 ms 2740 KB Output is correct
59 Correct 255 ms 21420 KB Output is correct
60 Correct 275 ms 21572 KB Output is correct
61 Correct 236 ms 21508 KB Output is correct
62 Correct 1 ms 304 KB Output is correct
63 Correct 273 ms 20652 KB Output is correct
64 Correct 143 ms 21316 KB Output is correct
65 Correct 167 ms 21316 KB Output is correct
66 Correct 142 ms 21404 KB Output is correct
67 Correct 126 ms 21420 KB Output is correct
68 Correct 132 ms 21516 KB Output is correct
69 Correct 162 ms 21424 KB Output is correct
70 Correct 15 ms 2752 KB Output is correct
71 Correct 15 ms 2656 KB Output is correct
72 Correct 14 ms 2632 KB Output is correct
73 Correct 15 ms 2620 KB Output is correct
74 Correct 16 ms 2636 KB Output is correct
75 Correct 15 ms 2632 KB Output is correct
76 Correct 15 ms 2636 KB Output is correct
77 Correct 15 ms 2616 KB Output is correct
78 Correct 16 ms 2604 KB Output is correct
79 Correct 19 ms 2640 KB Output is correct
80 Correct 18 ms 2752 KB Output is correct
81 Correct 14 ms 2724 KB Output is correct
82 Correct 15 ms 2628 KB Output is correct
83 Correct 15 ms 2644 KB Output is correct
84 Correct 15 ms 2616 KB Output is correct
85 Correct 15 ms 2616 KB Output is correct
86 Correct 14 ms 2628 KB Output is correct
87 Correct 16 ms 2624 KB Output is correct
88 Correct 19 ms 2748 KB Output is correct
89 Correct 15 ms 2748 KB Output is correct
90 Correct 15 ms 2628 KB Output is correct