답안 #679573

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
679573 2023-01-08T14:41:06 Z minhcool Dango Maker (JOI18_dango_maker) C++17
100 / 100
1249 ms 18352 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 3e3 + 5;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n, m;

char c[N][N];

int dp[2 * N][3][3];

bool ck(int x, int y, int dir){
	if(dir == 2) return 0;
	if(!dir){
		if(y >= (m - 1)) return 0;
		return (c[x][y] == 'R' && c[x][y + 1] == 'G' && c[x][y + 2] == 'W');
	}
	else{
		if(x >= (n - 1)) return 0;
		return (c[x][y] == 'R' && c[x + 1][y] == 'G' && c[x + 2][y] == 'W');
	}
}

void process(){
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++) cin >> c[i][j];
	}
	int answer = 0;
	for(int i = 2; i <= (n + m); i++){
		int sta = max(i - m, 1LL), en = min(n, i - 1);
		for(int j = sta; j <= en; j++){
			for(int k = 0; k < 3; k++){
				for(int h = 0; h < 3; h++) dp[j][k][h] = -oo;
			}
		}
		dp[sta][2][0] = 0;
		dp[sta][0][0] = ck(sta, i - sta, 0);
		dp[sta][1][0] = ck(sta, i - sta, 1);
		for(int j = sta; j < en; j++){
			for(int k = 0; k <= 2; k++){
				for(int h = 0; h <= 2; h++){
					for(int nxt = 0; nxt <= 2; nxt++){
						if(nxt == 0){
							if(k == 1 || h == 1) continue;
						}
						dp[j + 1][nxt][k] = max(dp[j + 1][nxt][k], dp[j][k][h] + ck(j + 1, i - (j + 1), nxt));
					}
				}
			}
		}
		int temp = -1;
		for(int i = 0; i <= 2; i++){
			for(int j = 0; j <= 2; j++) temp = max(temp, dp[en][i][j]);
		}
		//cout << i << " " << temp << "\n";
		answer += temp;
	}
	cout << answer << "\n";
}

signed main(){
	ios_base::sync_with_stdio(0);
	int t = 1;
	//cin >> t;
	while(t--) process();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 328 KB Output is correct
7 Correct 0 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 328 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 328 KB Output is correct
7 Correct 0 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 328 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 328 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 324 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 324 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 324 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 0 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 328 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 0 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 328 KB Output is correct
7 Correct 0 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 328 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 1 ms 328 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 324 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 324 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 324 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 0 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 328 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 0 ms 340 KB Output is correct
52 Correct 1 ms 340 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 4 ms 9244 KB Output is correct
56 Correct 3 ms 340 KB Output is correct
57 Correct 5 ms 6360 KB Output is correct
58 Correct 142 ms 4296 KB Output is correct
59 Correct 1244 ms 18076 KB Output is correct
60 Correct 1249 ms 18244 KB Output is correct
61 Correct 1246 ms 18236 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1199 ms 17844 KB Output is correct
64 Correct 1163 ms 18072 KB Output is correct
65 Correct 1160 ms 18080 KB Output is correct
66 Correct 1160 ms 18072 KB Output is correct
67 Correct 1220 ms 18352 KB Output is correct
68 Correct 1198 ms 18236 KB Output is correct
69 Correct 1216 ms 18132 KB Output is correct
70 Correct 133 ms 4268 KB Output is correct
71 Correct 131 ms 4396 KB Output is correct
72 Correct 133 ms 4304 KB Output is correct
73 Correct 130 ms 4300 KB Output is correct
74 Correct 131 ms 4280 KB Output is correct
75 Correct 132 ms 4300 KB Output is correct
76 Correct 138 ms 4216 KB Output is correct
77 Correct 129 ms 4188 KB Output is correct
78 Correct 132 ms 4300 KB Output is correct
79 Correct 129 ms 4172 KB Output is correct
80 Correct 130 ms 4260 KB Output is correct
81 Correct 131 ms 4272 KB Output is correct
82 Correct 128 ms 4204 KB Output is correct
83 Correct 131 ms 4268 KB Output is correct
84 Correct 130 ms 4340 KB Output is correct
85 Correct 131 ms 4332 KB Output is correct
86 Correct 129 ms 4172 KB Output is correct
87 Correct 128 ms 4204 KB Output is correct
88 Correct 129 ms 4416 KB Output is correct
89 Correct 132 ms 4300 KB Output is correct
90 Correct 129 ms 4252 KB Output is correct