Submission #940877

# Submission time Handle Problem Language Result Execution time Memory
940877 2024-03-07T21:36:39 Z lovrot Dango Maker (JOI18_dango_maker) C++17
100 / 100
460 ms 124528 KB
#include <cstdio> 
#include <algorithm> 
#include <vector>

using namespace std; 

const int N = 3010; 

int n, m;
char C[N][N]; 

bool stick(int x, int y, int d) {
	if(d == 1) return y > 0 && y < m - 1 && C[x][y] == 'G' && C[x][y - 1] == 'R' && C[x][y + 1] == 'W';
	return x > 0 && x < n - 1 && C[x][y] == 'G' && C[x - 1][y] == 'R' && C[x + 1][y] == 'W';
}

int DP[N][N][3];

int main() {
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; ++i) 
		for(int j = 0; j < m; ++j) scanf(" %c", &C[i][j]);
	
	int ans = 0;

	for(int i = 0; i < n; ++i) 
		for(int j = 0; j < m; ++j) {
			int *u = DP[i][j];
			u[0] = 0;
			u[1] = stick(i, j, 1);
			u[2] = stick(i, j, 2); 
			if(i > 0 && j < m - 1) {
				int *v = DP[i - 1][j + 1]; 
				u[0] = max(u[0], max({v[0], v[1], v[2]}));
				u[1] = max(u[1], stick(i, j, 1) + max(v[0], v[1]));
				u[2] = max(u[2], stick(i, j, 2) + max(v[0], v[2]));
//				if(i == 3 && j == 1) printf("%d %d %d\n", v[0], v[1], v[2]);
			}
			if(i == n - 1 || j == 0) ans += max({u[0], u[1], u[2]});
//			printf("{%d %d %d}%c", u[0], u[1], u[2], " \n"[j == m - 1]);
		}

	printf("%d\n", ans);
	return 0;
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
dango_maker.cpp:22:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   for(int j = 0; j < m; ++j) scanf(" %c", &C[i][j]);
      |                              ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2400 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 1 ms 2476 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2648 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2400 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 1 ms 2476 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2648 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 0 ms 2476 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 2 ms 2648 KB Output is correct
26 Correct 0 ms 2396 KB Output is correct
27 Correct 0 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 0 ms 2476 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2480 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2392 KB Output is correct
46 Correct 0 ms 2396 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2648 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 1 ms 2392 KB Output is correct
53 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2400 KB Output is correct
2 Correct 2 ms 2396 KB Output is correct
3 Correct 1 ms 2476 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2648 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 0 ms 2476 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 2 ms 2648 KB Output is correct
26 Correct 0 ms 2396 KB Output is correct
27 Correct 0 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 0 ms 2476 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2480 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2392 KB Output is correct
46 Correct 0 ms 2396 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2648 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 1 ms 2392 KB Output is correct
53 Correct 0 ms 2396 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 26 ms 76348 KB Output is correct
56 Correct 1 ms 2652 KB Output is correct
57 Correct 9 ms 69212 KB Output is correct
58 Correct 51 ms 40860 KB Output is correct
59 Correct 432 ms 124240 KB Output is correct
60 Correct 460 ms 124304 KB Output is correct
61 Correct 440 ms 124336 KB Output is correct
62 Correct 2 ms 2392 KB Output is correct
63 Correct 421 ms 123988 KB Output is correct
64 Correct 380 ms 124244 KB Output is correct
65 Correct 378 ms 124296 KB Output is correct
66 Correct 393 ms 124528 KB Output is correct
67 Correct 374 ms 124280 KB Output is correct
68 Correct 386 ms 124300 KB Output is correct
69 Correct 409 ms 124244 KB Output is correct
70 Correct 44 ms 40788 KB Output is correct
71 Correct 44 ms 40788 KB Output is correct
72 Correct 44 ms 40788 KB Output is correct
73 Correct 48 ms 40788 KB Output is correct
74 Correct 44 ms 40792 KB Output is correct
75 Correct 46 ms 40784 KB Output is correct
76 Correct 55 ms 40848 KB Output is correct
77 Correct 45 ms 40856 KB Output is correct
78 Correct 43 ms 40784 KB Output is correct
79 Correct 51 ms 40788 KB Output is correct
80 Correct 44 ms 40788 KB Output is correct
81 Correct 44 ms 40856 KB Output is correct
82 Correct 48 ms 40788 KB Output is correct
83 Correct 56 ms 40728 KB Output is correct
84 Correct 44 ms 40828 KB Output is correct
85 Correct 44 ms 40712 KB Output is correct
86 Correct 46 ms 40888 KB Output is correct
87 Correct 47 ms 40876 KB Output is correct
88 Correct 43 ms 40852 KB Output is correct
89 Correct 48 ms 40788 KB Output is correct
90 Correct 44 ms 40788 KB Output is correct