답안 #547420

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
547420 2022-04-10T16:20:41 Z MilosMilutinovic Dango Maker (JOI18_dango_maker) C++14
100 / 100
198 ms 88440 KB
#include <stdio.h>

#define N   3000

int max(int a, int b) { return a > b ? a : b; }

char s[N][N]; int dp[N + N][3], du[N][N], dr[N][N];

int main() {
	int n, m, i, j;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%s", s[i]);
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++) {
			if (j > 0 && j < m - 1 && s[i][j - 1] == 'R' && s[i][j] == 'G' && s[i][j + 1] == 'W')
				dr[i][j] = 1;
			if (i > 0 && i < n - 1 && s[i - 1][j] == 'R' && s[i][j] == 'G' && s[i + 1][j] == 'W')
				du[i][j] = 1;
		}
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++) {
			int i_, dp_[3];

			dp_[1] = dp_[2] = 0;
			dp_[0] = max(max(dp[i + j][0], dp[i + j][1]), dp[i + j][2]);
			if (dr[i][j] == 1)
				for (i_ = 0; i_ < 3; i_++)
					if (i_ != 2)
						dp_[1] = max(dp_[1], dp[i + j][i_] + 1);
			if (du[i][j] == 1)
				for (i_ = 0; i_ < 3; i_++)
					if (i_ != 1)
						dp_[2] = max(dp_[2], dp[i + j][i_] + 1);
			for (i_ = 0; i_ < 3; i_++)
				dp[i + j][i_] = dp_[i_];
		}
	int ans = 0;
	for (i = 0; i < n + m; i++)
		ans += max(max(dp[i][0], dp[i][1]), dp[i][2]);
	printf("%d\n", ans);
	return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%s", s[i]);
      |   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 288 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 288 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 288 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 292 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 292 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 292 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 292 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 0 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 292 KB Output is correct
42 Correct 1 ms 268 KB Output is correct
43 Correct 1 ms 292 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 288 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 0 ms 340 KB Output is correct
51 Correct 1 ms 352 KB Output is correct
52 Correct 0 ms 340 KB Output is correct
53 Correct 1 ms 296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 288 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 288 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 292 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 292 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 292 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 292 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 0 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 292 KB Output is correct
42 Correct 1 ms 268 KB Output is correct
43 Correct 1 ms 292 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 288 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 0 ms 340 KB Output is correct
51 Correct 1 ms 352 KB Output is correct
52 Correct 0 ms 340 KB Output is correct
53 Correct 1 ms 296 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 7 ms 9772 KB Output is correct
56 Correct 1 ms 468 KB Output is correct
57 Correct 8 ms 16096 KB Output is correct
58 Correct 27 ms 19628 KB Output is correct
59 Correct 194 ms 88328 KB Output is correct
60 Correct 178 ms 88380 KB Output is correct
61 Correct 198 ms 88316 KB Output is correct
62 Correct 0 ms 340 KB Output is correct
63 Correct 174 ms 88088 KB Output is correct
64 Correct 108 ms 88380 KB Output is correct
65 Correct 104 ms 88440 KB Output is correct
66 Correct 102 ms 88408 KB Output is correct
67 Correct 107 ms 33692 KB Output is correct
68 Correct 85 ms 33816 KB Output is correct
69 Correct 101 ms 43768 KB Output is correct
70 Correct 16 ms 20004 KB Output is correct
71 Correct 17 ms 19920 KB Output is correct
72 Correct 20 ms 19924 KB Output is correct
73 Correct 17 ms 19924 KB Output is correct
74 Correct 19 ms 19892 KB Output is correct
75 Correct 19 ms 19976 KB Output is correct
76 Correct 16 ms 19936 KB Output is correct
77 Correct 17 ms 19932 KB Output is correct
78 Correct 17 ms 19912 KB Output is correct
79 Correct 17 ms 19932 KB Output is correct
80 Correct 17 ms 20008 KB Output is correct
81 Correct 18 ms 19948 KB Output is correct
82 Correct 17 ms 19904 KB Output is correct
83 Correct 17 ms 19936 KB Output is correct
84 Correct 17 ms 19936 KB Output is correct
85 Correct 17 ms 20008 KB Output is correct
86 Correct 17 ms 19924 KB Output is correct
87 Correct 17 ms 19976 KB Output is correct
88 Correct 17 ms 19928 KB Output is correct
89 Correct 17 ms 20052 KB Output is correct
90 Correct 17 ms 20016 KB Output is correct