답안 #330243

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
330243 2020-11-24T08:48:05 Z Seanliu Dango Maker (JOI18_dango_maker) C++14
100 / 100
424 ms 186604 KB
#include <iostream>
#include <string.h>
using namespace std;

const int maxN = 3e3 + 326;
string mp[maxN];

int N, M, dp[maxN][maxN][4], ans[maxN * 2], r;
bool canV[maxN][maxN], canH[maxN][maxN];
int main(){
	cin >> N >> M;
	for(int i = 0; i < N; i++){
		cin >> mp[i];
	}
	//for(int i = 0; i < N; i++) for(int j = 0; j < M; j++) cout << mp[i][j] << " \n"[j == M - 1];
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			canV[i][j] = i < N - 2 && (mp[i][j] == 'R' && mp[i + 1][j] == 'G' && mp[i + 2][j] == 'W');
			canH[i][j] = j < M - 2 && (mp[i][j] == 'R' && mp[i][j + 1] == 'G' && mp[i][j + 2] == 'W');
			if(i - 1 < 0 || j + 1 >= M){
				dp[i][j][2] = (canV[i][j]);	
				dp[i][j][0] = (canH[i][j]);	
				ans[i + j] = max(ans[i + j], dp[i][j][2]);
				ans[i + j] = max(ans[i + j], dp[i][j][0]);
				//cout << "dp[" << i << "][" << j << "][" << 0 << "] = " << dp[i][j][0] << endl;
				//cout << "dp[" << i << "][" << j << "][" << 2 << "] = " << dp[i][j][2] << endl;
			} else {
				dp[i][j][0] = max(max(dp[i - 1][j + 1][1], dp[i - 1][j + 1][0]), canH[i][j] * (dp[i - 1][j + 1][0] + 1));
				dp[i][j][1] = max(dp[i - 1][j + 1][2], dp[i - 1][j + 1][3]);
				if(canV[i][j]){
					dp[i][j][2] = max(dp[i - 1][j + 1][0], dp[i - 1][j + 1][1]) + 1;
					dp[i][j][3] = max(dp[i - 1][j + 1][2], dp[i - 1][j + 1][3]) + 1;
				}
				for(int k = 0; k < 4; k++){
					ans[i + j] = max(ans[i + j], dp[i][j][k]);
					//cout << "dp[" << i << "][" << j << "][" << k << "] = " << dp[i][j][k] << endl;
				}
			}
		}
	}
	/*
	for(int i = 0; i < N; i++) for(int j = 0; j < M; j++) cout << canV[i][j] << " \n"[j == M - 1];
	cout << endl;
	for(int i = 0; i < N; i++) for(int j = 0; j < M; j++) cout << canH[i][j] << " \n"[j == M - 1];
	cout << endl;
	*/
	for(int i = 0; i < N + M; i++) r += ans[i];
	cout << r << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 1 ms 492 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 1 ms 492 KB Output is correct
27 Correct 1 ms 492 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 1 ms 492 KB Output is correct
30 Correct 1 ms 492 KB Output is correct
31 Correct 1 ms 492 KB Output is correct
32 Correct 1 ms 492 KB Output is correct
33 Correct 1 ms 492 KB Output is correct
34 Correct 1 ms 492 KB Output is correct
35 Correct 1 ms 492 KB Output is correct
36 Correct 1 ms 492 KB Output is correct
37 Correct 1 ms 492 KB Output is correct
38 Correct 1 ms 492 KB Output is correct
39 Correct 1 ms 492 KB Output is correct
40 Correct 1 ms 492 KB Output is correct
41 Correct 1 ms 492 KB Output is correct
42 Correct 1 ms 492 KB Output is correct
43 Correct 1 ms 492 KB Output is correct
44 Correct 1 ms 492 KB Output is correct
45 Correct 1 ms 492 KB Output is correct
46 Correct 1 ms 492 KB Output is correct
47 Correct 1 ms 492 KB Output is correct
48 Correct 1 ms 492 KB Output is correct
49 Correct 1 ms 492 KB Output is correct
50 Correct 1 ms 492 KB Output is correct
51 Correct 1 ms 492 KB Output is correct
52 Correct 1 ms 492 KB Output is correct
53 Correct 1 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
7 Correct 1 ms 492 KB Output is correct
8 Correct 1 ms 492 KB Output is correct
9 Correct 1 ms 512 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 1 ms 492 KB Output is correct
13 Correct 1 ms 492 KB Output is correct
14 Correct 1 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 1 ms 492 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 1 ms 492 KB Output is correct
24 Correct 1 ms 492 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 1 ms 492 KB Output is correct
27 Correct 1 ms 492 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
29 Correct 1 ms 492 KB Output is correct
30 Correct 1 ms 492 KB Output is correct
31 Correct 1 ms 492 KB Output is correct
32 Correct 1 ms 492 KB Output is correct
33 Correct 1 ms 492 KB Output is correct
34 Correct 1 ms 492 KB Output is correct
35 Correct 1 ms 492 KB Output is correct
36 Correct 1 ms 492 KB Output is correct
37 Correct 1 ms 492 KB Output is correct
38 Correct 1 ms 492 KB Output is correct
39 Correct 1 ms 492 KB Output is correct
40 Correct 1 ms 492 KB Output is correct
41 Correct 1 ms 492 KB Output is correct
42 Correct 1 ms 492 KB Output is correct
43 Correct 1 ms 492 KB Output is correct
44 Correct 1 ms 492 KB Output is correct
45 Correct 1 ms 492 KB Output is correct
46 Correct 1 ms 492 KB Output is correct
47 Correct 1 ms 492 KB Output is correct
48 Correct 1 ms 492 KB Output is correct
49 Correct 1 ms 492 KB Output is correct
50 Correct 1 ms 492 KB Output is correct
51 Correct 1 ms 492 KB Output is correct
52 Correct 1 ms 492 KB Output is correct
53 Correct 1 ms 492 KB Output is correct
54 Correct 1 ms 492 KB Output is correct
55 Correct 18 ms 32236 KB Output is correct
56 Correct 1 ms 748 KB Output is correct
57 Correct 12 ms 21868 KB Output is correct
58 Correct 53 ms 29548 KB Output is correct
59 Correct 424 ms 186220 KB Output is correct
60 Correct 424 ms 186312 KB Output is correct
61 Correct 420 ms 186224 KB Output is correct
62 Correct 1 ms 620 KB Output is correct
63 Correct 414 ms 181612 KB Output is correct
64 Correct 386 ms 186604 KB Output is correct
65 Correct 373 ms 186348 KB Output is correct
66 Correct 373 ms 186476 KB Output is correct
67 Correct 370 ms 186476 KB Output is correct
68 Correct 394 ms 186476 KB Output is correct
69 Correct 379 ms 186320 KB Output is correct
70 Correct 54 ms 29548 KB Output is correct
71 Correct 47 ms 29548 KB Output is correct
72 Correct 49 ms 29548 KB Output is correct
73 Correct 47 ms 29604 KB Output is correct
74 Correct 46 ms 29548 KB Output is correct
75 Correct 47 ms 29548 KB Output is correct
76 Correct 48 ms 29548 KB Output is correct
77 Correct 46 ms 29548 KB Output is correct
78 Correct 47 ms 29548 KB Output is correct
79 Correct 48 ms 29548 KB Output is correct
80 Correct 46 ms 29548 KB Output is correct
81 Correct 46 ms 29548 KB Output is correct
82 Correct 46 ms 29548 KB Output is correct
83 Correct 47 ms 29548 KB Output is correct
84 Correct 46 ms 29548 KB Output is correct
85 Correct 46 ms 29548 KB Output is correct
86 Correct 46 ms 29548 KB Output is correct
87 Correct 46 ms 29548 KB Output is correct
88 Correct 47 ms 29548 KB Output is correct
89 Correct 47 ms 29548 KB Output is correct
90 Correct 46 ms 29548 KB Output is correct