답안 #64257

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64257 2018-08-03T17:46:04 Z keko37 Dango Maker (JOI18_dango_maker) C++14
100 / 100
1746 ms 254756 KB
#include<iostream>
#include<cstring>

using namespace std;

const int MAXN = 3005;

int n, m, a, b, sol;
char l[MAXN] [MAXN];
int dp[MAXN] [MAXN] [4];

bool ok (int x, int y, int d) {
	if (d == 0) {
		return l[x] [y] == 'R' && l[x+1] [y] == 'G' && l[x+2] [y] == 'W';
	} else {
		return l[x] [y] == 'R' && l[x] [y+1] == 'G' && l[x] [y+2] == 'W';
	}
}

int f (int x, int y, int mask) {
	if (l[x] [y] != 'R' || x < 0) return 0;
	if (dp[x] [y] [mask] != -1) return dp[x] [y] [mask];
	int res = 0;
	res = max(res, f(x-1, y+1, (2*mask)%4));
	res = max(res, f(x-2, y+2, 0));
	if (ok(x, y, 0) && mask == 0) {
		res = max(res, 1+f(x-1, y+1, 0));
		res = max(res, 1+f(x-2, y+2, 0));
	}
	if (ok(x, y, 1)) {
		res = max(res, 1+f(x-1, y+1, (mask*2 + 1)%4));
		res = max(res, 1+f(x-2, y+2, 2));
	}
	dp[x] [y] [mask] = res;
	return res;
}

int main () {
	memset(dp, -1, sizeof dp);
	cin >> n >> m;
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			cin >> l[i] [j];
		}
	}
	for (int i=n-1; i>=0; i--) {
		for (int j=m-1; j>=0; j--) {
			if (dp[i] [j] [0] == -1) {
				sol += f(i, j, 0);
			}
		}
	}
	cout << sol;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 140 ms 141688 KB Output is correct
2 Correct 136 ms 141924 KB Output is correct
3 Correct 129 ms 141924 KB Output is correct
4 Correct 120 ms 141924 KB Output is correct
5 Correct 124 ms 141924 KB Output is correct
6 Correct 115 ms 141948 KB Output is correct
7 Correct 116 ms 142188 KB Output is correct
8 Correct 120 ms 142188 KB Output is correct
9 Correct 111 ms 142188 KB Output is correct
10 Correct 118 ms 142188 KB Output is correct
11 Correct 133 ms 142188 KB Output is correct
12 Correct 111 ms 142188 KB Output is correct
13 Correct 134 ms 142188 KB Output is correct
14 Correct 135 ms 142188 KB Output is correct
15 Correct 120 ms 142188 KB Output is correct
16 Correct 123 ms 142188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 140 ms 141688 KB Output is correct
2 Correct 136 ms 141924 KB Output is correct
3 Correct 129 ms 141924 KB Output is correct
4 Correct 120 ms 141924 KB Output is correct
5 Correct 124 ms 141924 KB Output is correct
6 Correct 115 ms 141948 KB Output is correct
7 Correct 116 ms 142188 KB Output is correct
8 Correct 120 ms 142188 KB Output is correct
9 Correct 111 ms 142188 KB Output is correct
10 Correct 118 ms 142188 KB Output is correct
11 Correct 133 ms 142188 KB Output is correct
12 Correct 111 ms 142188 KB Output is correct
13 Correct 134 ms 142188 KB Output is correct
14 Correct 135 ms 142188 KB Output is correct
15 Correct 120 ms 142188 KB Output is correct
16 Correct 123 ms 142188 KB Output is correct
17 Correct 114 ms 142188 KB Output is correct
18 Correct 134 ms 142188 KB Output is correct
19 Correct 117 ms 142188 KB Output is correct
20 Correct 125 ms 142188 KB Output is correct
21 Correct 113 ms 142188 KB Output is correct
22 Correct 129 ms 142188 KB Output is correct
23 Correct 123 ms 142188 KB Output is correct
24 Correct 123 ms 142188 KB Output is correct
25 Correct 130 ms 142188 KB Output is correct
26 Correct 122 ms 142188 KB Output is correct
27 Correct 127 ms 142188 KB Output is correct
28 Correct 121 ms 142188 KB Output is correct
29 Correct 131 ms 142188 KB Output is correct
30 Correct 134 ms 142188 KB Output is correct
31 Correct 129 ms 142188 KB Output is correct
32 Correct 134 ms 142188 KB Output is correct
33 Correct 148 ms 142188 KB Output is correct
34 Correct 128 ms 142188 KB Output is correct
35 Correct 114 ms 142188 KB Output is correct
36 Correct 118 ms 142188 KB Output is correct
37 Correct 110 ms 142188 KB Output is correct
38 Correct 108 ms 142188 KB Output is correct
39 Correct 112 ms 142188 KB Output is correct
40 Correct 131 ms 142188 KB Output is correct
41 Correct 134 ms 142188 KB Output is correct
42 Correct 128 ms 142188 KB Output is correct
43 Correct 130 ms 142188 KB Output is correct
44 Correct 132 ms 142188 KB Output is correct
45 Correct 133 ms 142188 KB Output is correct
46 Correct 122 ms 142188 KB Output is correct
47 Correct 133 ms 142188 KB Output is correct
48 Correct 132 ms 142188 KB Output is correct
49 Correct 138 ms 142196 KB Output is correct
50 Correct 132 ms 142196 KB Output is correct
51 Correct 135 ms 142324 KB Output is correct
52 Correct 131 ms 142324 KB Output is correct
53 Correct 119 ms 142324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 140 ms 141688 KB Output is correct
2 Correct 136 ms 141924 KB Output is correct
3 Correct 129 ms 141924 KB Output is correct
4 Correct 120 ms 141924 KB Output is correct
5 Correct 124 ms 141924 KB Output is correct
6 Correct 115 ms 141948 KB Output is correct
7 Correct 116 ms 142188 KB Output is correct
8 Correct 120 ms 142188 KB Output is correct
9 Correct 111 ms 142188 KB Output is correct
10 Correct 118 ms 142188 KB Output is correct
11 Correct 133 ms 142188 KB Output is correct
12 Correct 111 ms 142188 KB Output is correct
13 Correct 134 ms 142188 KB Output is correct
14 Correct 135 ms 142188 KB Output is correct
15 Correct 120 ms 142188 KB Output is correct
16 Correct 123 ms 142188 KB Output is correct
17 Correct 114 ms 142188 KB Output is correct
18 Correct 134 ms 142188 KB Output is correct
19 Correct 117 ms 142188 KB Output is correct
20 Correct 125 ms 142188 KB Output is correct
21 Correct 113 ms 142188 KB Output is correct
22 Correct 129 ms 142188 KB Output is correct
23 Correct 123 ms 142188 KB Output is correct
24 Correct 123 ms 142188 KB Output is correct
25 Correct 130 ms 142188 KB Output is correct
26 Correct 122 ms 142188 KB Output is correct
27 Correct 127 ms 142188 KB Output is correct
28 Correct 121 ms 142188 KB Output is correct
29 Correct 131 ms 142188 KB Output is correct
30 Correct 134 ms 142188 KB Output is correct
31 Correct 129 ms 142188 KB Output is correct
32 Correct 134 ms 142188 KB Output is correct
33 Correct 148 ms 142188 KB Output is correct
34 Correct 128 ms 142188 KB Output is correct
35 Correct 114 ms 142188 KB Output is correct
36 Correct 118 ms 142188 KB Output is correct
37 Correct 110 ms 142188 KB Output is correct
38 Correct 108 ms 142188 KB Output is correct
39 Correct 112 ms 142188 KB Output is correct
40 Correct 131 ms 142188 KB Output is correct
41 Correct 134 ms 142188 KB Output is correct
42 Correct 128 ms 142188 KB Output is correct
43 Correct 130 ms 142188 KB Output is correct
44 Correct 132 ms 142188 KB Output is correct
45 Correct 133 ms 142188 KB Output is correct
46 Correct 122 ms 142188 KB Output is correct
47 Correct 133 ms 142188 KB Output is correct
48 Correct 132 ms 142188 KB Output is correct
49 Correct 138 ms 142196 KB Output is correct
50 Correct 132 ms 142196 KB Output is correct
51 Correct 135 ms 142324 KB Output is correct
52 Correct 131 ms 142324 KB Output is correct
53 Correct 119 ms 142324 KB Output is correct
54 Correct 138 ms 142324 KB Output is correct
55 Correct 132 ms 150988 KB Output is correct
56 Correct 130 ms 150988 KB Output is correct
57 Correct 122 ms 150988 KB Output is correct
58 Correct 210 ms 150988 KB Output is correct
59 Correct 1203 ms 161044 KB Output is correct
60 Correct 1202 ms 169792 KB Output is correct
61 Correct 1215 ms 178644 KB Output is correct
62 Correct 110 ms 178644 KB Output is correct
63 Correct 1380 ms 187180 KB Output is correct
64 Correct 1676 ms 196184 KB Output is correct
65 Correct 1701 ms 205008 KB Output is correct
66 Correct 1746 ms 213876 KB Output is correct
67 Correct 999 ms 222344 KB Output is correct
68 Correct 864 ms 231216 KB Output is correct
69 Correct 1129 ms 239900 KB Output is correct
70 Correct 269 ms 239900 KB Output is correct
71 Correct 260 ms 239900 KB Output is correct
72 Correct 325 ms 239900 KB Output is correct
73 Correct 276 ms 239900 KB Output is correct
74 Correct 280 ms 239900 KB Output is correct
75 Correct 289 ms 240056 KB Output is correct
76 Correct 330 ms 241092 KB Output is correct
77 Correct 292 ms 241888 KB Output is correct
78 Correct 255 ms 243024 KB Output is correct
79 Correct 278 ms 243940 KB Output is correct
80 Correct 283 ms 244864 KB Output is correct
81 Correct 276 ms 245964 KB Output is correct
82 Correct 248 ms 246828 KB Output is correct
83 Correct 233 ms 247896 KB Output is correct
84 Correct 252 ms 248876 KB Output is correct
85 Correct 245 ms 249856 KB Output is correct
86 Correct 300 ms 250836 KB Output is correct
87 Correct 254 ms 251816 KB Output is correct
88 Correct 271 ms 252792 KB Output is correct
89 Correct 236 ms 253716 KB Output is correct
90 Correct 251 ms 254756 KB Output is correct