답안 #291705

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
291705 2020-09-05T16:56:57 Z reymontada61 Dango Maker (JOI18_dango_maker) C++14
100 / 100
759 ms 80012 KB
#include <bits/stdc++.h>
using namespace std;

const int MXN = 3005;
int n, m;
int grid[MXN][MXN];
int can[MXN][MXN];
int dp[MXN][3];

signed main() {

	cin >> n >> m;
	for (int i=1; i<=n; i++) {
		string s;
		cin >> s;
		for (int j=1; j<=m; j++) {
			if (s[j-1] == 'R') grid[i][j] = 1;
			if (s[j-1] == 'G') grid[i][j] = 2;
			if (s[j-1] == 'W') grid[i][j] = 3;
		}
	}
	
	
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=m; j++) {
			if (grid[i][j] == 2) {
				if (grid[i-1][j] == 1 && grid[i+1][j] == 3) {
					can[i][j] += 1;
				}
				if (grid[i][j-1] == 1 && grid[i][j+1] == 3) {
					can[i][j] += 2;
				}
			}
		}
	}
	
	int ans = 0;
	
	for (int diag=2; diag<=n+m; diag++) {
		dp[0][0] = dp[0][1] = dp[0][2] = 0;
		int here = 0;
		vector<int> vc;
		vc.push_back(-1);
		for (int i=1; i<=n; i++) {
			int j = diag - i;
			if (j >= 1 && j <= m) {
				vc.push_back(can[i][j]);
			}
		}
		for (int i=1; i<vc.size(); i++) {
			dp[i][0] = dp[i][1] = dp[i][2] = 0;
			dp[i][0] = max(max(dp[i-1][0], dp[i-1][1]), dp[i-1][2]);
			if (vc[i] & 1) {
				dp[i][1] = max(dp[i][1], 1 + max(dp[i-1][0], dp[i-1][1]));
			}
			if (vc[i] & 2) {
				dp[i][2] = max(dp[i][2], 1 + max(dp[i-1][0], dp[i-1][2]));
			}
			here = max(here, max(max(dp[i][0], dp[i][1]), dp[i][2]));
		}
		ans += here;
	}
	
	cout << ans << endl;
	
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:50:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   for (int i=1; i<vc.size(); i++) {
      |                 ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 0 ms 384 KB Output is correct
25 Correct 0 ms 384 KB Output is correct
26 Correct 0 ms 384 KB Output is correct
27 Correct 0 ms 384 KB Output is correct
28 Correct 0 ms 384 KB Output is correct
29 Correct 0 ms 384 KB Output is correct
30 Correct 0 ms 384 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 0 ms 384 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 0 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 1 ms 384 KB Output is correct
39 Correct 1 ms 384 KB Output is correct
40 Correct 1 ms 384 KB Output is correct
41 Correct 1 ms 384 KB Output is correct
42 Correct 1 ms 384 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 1 ms 384 KB Output is correct
45 Correct 1 ms 384 KB Output is correct
46 Correct 0 ms 384 KB Output is correct
47 Correct 1 ms 384 KB Output is correct
48 Correct 0 ms 384 KB Output is correct
49 Correct 1 ms 384 KB Output is correct
50 Correct 1 ms 384 KB Output is correct
51 Correct 1 ms 384 KB Output is correct
52 Correct 1 ms 384 KB Output is correct
53 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 0 ms 384 KB Output is correct
25 Correct 0 ms 384 KB Output is correct
26 Correct 0 ms 384 KB Output is correct
27 Correct 0 ms 384 KB Output is correct
28 Correct 0 ms 384 KB Output is correct
29 Correct 0 ms 384 KB Output is correct
30 Correct 0 ms 384 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 0 ms 384 KB Output is correct
34 Correct 1 ms 384 KB Output is correct
35 Correct 0 ms 384 KB Output is correct
36 Correct 1 ms 384 KB Output is correct
37 Correct 1 ms 384 KB Output is correct
38 Correct 1 ms 384 KB Output is correct
39 Correct 1 ms 384 KB Output is correct
40 Correct 1 ms 384 KB Output is correct
41 Correct 1 ms 384 KB Output is correct
42 Correct 1 ms 384 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 1 ms 384 KB Output is correct
45 Correct 1 ms 384 KB Output is correct
46 Correct 0 ms 384 KB Output is correct
47 Correct 1 ms 384 KB Output is correct
48 Correct 0 ms 384 KB Output is correct
49 Correct 1 ms 384 KB Output is correct
50 Correct 1 ms 384 KB Output is correct
51 Correct 1 ms 384 KB Output is correct
52 Correct 1 ms 384 KB Output is correct
53 Correct 1 ms 384 KB Output is correct
54 Correct 1 ms 384 KB Output is correct
55 Correct 21 ms 12928 KB Output is correct
56 Correct 2 ms 512 KB Output is correct
57 Correct 15 ms 15488 KB Output is correct
58 Correct 85 ms 17076 KB Output is correct
59 Correct 750 ms 79932 KB Output is correct
60 Correct 754 ms 79992 KB Output is correct
61 Correct 759 ms 80012 KB Output is correct
62 Correct 1 ms 384 KB Output is correct
63 Correct 724 ms 79736 KB Output is correct
64 Correct 629 ms 79744 KB Output is correct
65 Correct 650 ms 80008 KB Output is correct
66 Correct 635 ms 79864 KB Output is correct
67 Correct 609 ms 60408 KB Output is correct
68 Correct 607 ms 60536 KB Output is correct
69 Correct 632 ms 66040 KB Output is correct
70 Correct 73 ms 17272 KB Output is correct
71 Correct 72 ms 17144 KB Output is correct
72 Correct 71 ms 17144 KB Output is correct
73 Correct 72 ms 17144 KB Output is correct
74 Correct 71 ms 17144 KB Output is correct
75 Correct 73 ms 17184 KB Output is correct
76 Correct 75 ms 17144 KB Output is correct
77 Correct 74 ms 17196 KB Output is correct
78 Correct 72 ms 17144 KB Output is correct
79 Correct 78 ms 17136 KB Output is correct
80 Correct 71 ms 17168 KB Output is correct
81 Correct 70 ms 17200 KB Output is correct
82 Correct 72 ms 17252 KB Output is correct
83 Correct 72 ms 17272 KB Output is correct
84 Correct 73 ms 17144 KB Output is correct
85 Correct 71 ms 17192 KB Output is correct
86 Correct 71 ms 17144 KB Output is correct
87 Correct 71 ms 17144 KB Output is correct
88 Correct 71 ms 17324 KB Output is correct
89 Correct 73 ms 17144 KB Output is correct
90 Correct 72 ms 17144 KB Output is correct