Submission #313194

# Submission time Handle Problem Language Result Execution time Memory
313194 2020-10-15T13:24:20 Z LucaDantas Dango Maker (JOI18_dango_maker) C++17
100 / 100
823 ms 221336 KB
#include<bits/stdc++.h>
using namespace std;

constexpr int maxn = 3e3+10;

int grid[maxn][maxn], v[maxn][maxn], h[maxn][maxn], n, m;
// 0 -> no one, 1 -> vertical, 2 -> horizontal
int dp[maxn][maxn][3], diag[2*maxn];

inline int pos(int i, int j) { return m*i+j; }

int main() {
	scanf("%d %d", &n, &m);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			char c; scanf(" %c", &c);
			grid[i][j] = (c=='R'?0:c=='G'?1:2);
		}
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(i && i < n-1 && grid[i][j] == 1 && grid[i-1][j] == 0 && grid[i+1][j] == 2)
				v[i][j] = 1;
			if(j && j < m-1 && grid[i][j] == 1 && grid[i][j-1] == 0 && grid[i][j+1] == 2)
				h[i][j] = 1;
		}
	}
	// fprintf(stderr, "i j 0 1 2\n");
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			// a gente pode colocar n-1 e m-1 pq se qualquer cara tiver nos limites
			// o valor dele vai ser 0 msm
			if(i>0 && j+1<m)
				for(int x : {0, 1, 2})
					dp[i][j][0] = max(dp[i][j][0], dp[i-1][j+1][x]);
			else
				dp[i][j][0] = 0;
			if(v[i][j]) {
				if(i>0 && j+1<m)
					for(int x : {0, 1})
						dp[i][j][1] = max(dp[i][j][1], dp[i-1][j+1][x]+1);
				else
					dp[i][j][1] = 1;
			}
			if(h[i][j]) {
				if(i>0 && j+1<m)
					for(int x : {0, 2})
						dp[i][j][2] = max(dp[i][j][2], dp[i-1][j+1][x]+1);
				else
					dp[i][j][2] = 1;
			}
			// fprintf(stderr, "%d %d %d %d %d\n", i, j, dp[i][j][0], dp[i][j][1], dp[i][j][2]);
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++) {
		int here = 0;
		for(int x : {0, 1, 2})
			here = max(here, dp[i][0][x]);
		ans += here;
	}
	for(int j = 1; j < m; j++) {
		int here = 0;
		for(int x : {0, 1, 2})
			here = max(here, dp[n-1][j][x]);
		ans += here;
	}
	printf("%d\n", ans);
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |  scanf("%d %d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~
dango_maker.cpp:16:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |    char c; scanf(" %c", &c);
      |            ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 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 1 ms 384 KB Output is correct
12 Correct 1 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 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 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 1 ms 384 KB Output is correct
12 Correct 1 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 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 512 KB Output is correct
34 Correct 1 ms 512 KB Output is correct
35 Correct 1 ms 512 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
38 Correct 1 ms 512 KB Output is correct
39 Correct 1 ms 512 KB Output is correct
40 Correct 1 ms 512 KB Output is correct
41 Correct 1 ms 512 KB Output is correct
42 Correct 1 ms 512 KB Output is correct
43 Correct 1 ms 512 KB Output is correct
44 Correct 1 ms 512 KB Output is correct
45 Correct 1 ms 544 KB Output is correct
46 Correct 1 ms 512 KB Output is correct
47 Correct 1 ms 512 KB Output is correct
48 Correct 1 ms 512 KB Output is correct
49 Correct 1 ms 512 KB Output is correct
50 Correct 1 ms 512 KB Output is correct
51 Correct 1 ms 512 KB Output is correct
52 Correct 1 ms 512 KB Output is correct
53 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 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 1 ms 384 KB Output is correct
12 Correct 1 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 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 512 KB Output is correct
21 Correct 1 ms 512 KB Output is correct
22 Correct 1 ms 512 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 512 KB Output is correct
29 Correct 1 ms 512 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 1 ms 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 512 KB Output is correct
34 Correct 1 ms 512 KB Output is correct
35 Correct 1 ms 512 KB Output is correct
36 Correct 1 ms 512 KB Output is correct
37 Correct 1 ms 512 KB Output is correct
38 Correct 1 ms 512 KB Output is correct
39 Correct 1 ms 512 KB Output is correct
40 Correct 1 ms 512 KB Output is correct
41 Correct 1 ms 512 KB Output is correct
42 Correct 1 ms 512 KB Output is correct
43 Correct 1 ms 512 KB Output is correct
44 Correct 1 ms 512 KB Output is correct
45 Correct 1 ms 544 KB Output is correct
46 Correct 1 ms 512 KB Output is correct
47 Correct 1 ms 512 KB Output is correct
48 Correct 1 ms 512 KB Output is correct
49 Correct 1 ms 512 KB Output is correct
50 Correct 1 ms 512 KB Output is correct
51 Correct 1 ms 512 KB Output is correct
52 Correct 1 ms 512 KB Output is correct
53 Correct 1 ms 512 KB Output is correct
54 Correct 1 ms 416 KB Output is correct
55 Correct 19 ms 25088 KB Output is correct
56 Correct 2 ms 640 KB Output is correct
57 Correct 17 ms 26752 KB Output is correct
58 Correct 102 ms 40568 KB Output is correct
59 Correct 823 ms 221304 KB Output is correct
60 Correct 806 ms 221176 KB Output is correct
61 Correct 808 ms 221308 KB Output is correct
62 Correct 1 ms 512 KB Output is correct
63 Correct 784 ms 220792 KB Output is correct
64 Correct 743 ms 221180 KB Output is correct
65 Correct 751 ms 221336 KB Output is correct
66 Correct 746 ms 221176 KB Output is correct
67 Correct 725 ms 166332 KB Output is correct
68 Correct 717 ms 166652 KB Output is correct
69 Correct 720 ms 176432 KB Output is correct
70 Correct 91 ms 40824 KB Output is correct
71 Correct 93 ms 40952 KB Output is correct
72 Correct 92 ms 40824 KB Output is correct
73 Correct 93 ms 40824 KB Output is correct
74 Correct 94 ms 40824 KB Output is correct
75 Correct 92 ms 40824 KB Output is correct
76 Correct 92 ms 40824 KB Output is correct
77 Correct 92 ms 40824 KB Output is correct
78 Correct 93 ms 40824 KB Output is correct
79 Correct 92 ms 40828 KB Output is correct
80 Correct 93 ms 40824 KB Output is correct
81 Correct 93 ms 40824 KB Output is correct
82 Correct 91 ms 40824 KB Output is correct
83 Correct 91 ms 40772 KB Output is correct
84 Correct 92 ms 40824 KB Output is correct
85 Correct 93 ms 40824 KB Output is correct
86 Correct 94 ms 40824 KB Output is correct
87 Correct 92 ms 40824 KB Output is correct
88 Correct 92 ms 40824 KB Output is correct
89 Correct 93 ms 40824 KB Output is correct
90 Correct 92 ms 40824 KB Output is correct