# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
537622 | 2022-03-15T09:59:00 Z | 79brue | Dango Maker (JOI18_dango_maker) | C++14 | 846 ms | 44448 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, m; int arr[3002][3002]; int ans; int state[3002]; int DP[3002][3]; const int trans[3][3] = { 0, 1, 1, 0, 1, -1000000, 0, -1000000, 1 }; int main(){ scanf("%d %d", &n, &m); for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ char c; scanf(" %c", &c); if(c=='R') arr[i][j] = 0; else if(c=='G') arr[i][j] = 1; else arr[i][j] = 2; } } for(int d=3; d<=n+m-1; d++){ for(int i=1; i<=n; i++){ state[i] = 0; DP[i][0] = DP[i][1] = DP[i][2] = -1e9; int j = d-i; if(j<1 || j>m || arr[i][j]!=1) continue; if(i>1 && i<n && arr[i-1][j]==0 && arr[i+1][j]==2) state[i] |= 1; if(j>1 && j<m && arr[i][j-1]==0 && arr[i][j+1]==2) state[i] |= 2; } for(int i=1; i<=n; i++){ for(int j=0; j<3; j++){ for(int k=0; k<3; k++){ if((k==1 && !(state[i]&1)) || (k==2 && !(state[i]&2))) continue; DP[i][k] = max(DP[i][k], DP[i-1][j] + trans[j][k]); } } } ans += max({DP[n][0], DP[n][1], DP[n][2]}); } printf("%d", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 312 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 312 KB | Output is correct |
14 | Correct | 1 ms | 308 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 312 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 312 KB | Output is correct |
14 | Correct | 1 ms | 308 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 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 | 308 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 312 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 308 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 312 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 1 ms | 340 KB | Output is correct |
37 | Correct | 1 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 | 340 KB | Output is correct |
42 | Correct | 1 ms | 316 KB | Output is correct |
43 | Correct | 1 ms | 316 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 | 312 KB | Output is correct |
48 | Correct | 1 ms | 316 KB | Output is correct |
49 | Correct | 1 ms | 340 KB | Output is correct |
50 | Correct | 1 ms | 340 KB | Output is correct |
51 | Correct | 1 ms | 340 KB | Output is correct |
52 | Correct | 1 ms | 340 KB | Output is correct |
53 | Correct | 1 ms | 312 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 312 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 312 KB | Output is correct |
14 | Correct | 1 ms | 308 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 0 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 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 | 308 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 312 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 308 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 312 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 340 KB | Output is correct |
33 | Correct | 1 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 1 ms | 340 KB | Output is correct |
37 | Correct | 1 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 | 340 KB | Output is correct |
42 | Correct | 1 ms | 316 KB | Output is correct |
43 | Correct | 1 ms | 316 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 | 312 KB | Output is correct |
48 | Correct | 1 ms | 316 KB | Output is correct |
49 | Correct | 1 ms | 340 KB | Output is correct |
50 | Correct | 1 ms | 340 KB | Output is correct |
51 | Correct | 1 ms | 340 KB | Output is correct |
52 | Correct | 1 ms | 340 KB | Output is correct |
53 | Correct | 1 ms | 312 KB | Output is correct |
54 | Correct | 1 ms | 212 KB | Output is correct |
55 | Correct | 154 ms | 12412 KB | Output is correct |
56 | Correct | 2 ms | 340 KB | Output is correct |
57 | Correct | 52 ms | 8404 KB | Output is correct |
58 | Correct | 86 ms | 9164 KB | Output is correct |
59 | Correct | 763 ms | 44380 KB | Output is correct |
60 | Correct | 846 ms | 44304 KB | Output is correct |
61 | Correct | 811 ms | 44448 KB | Output is correct |
62 | Correct | 1 ms | 340 KB | Output is correct |
63 | Correct | 772 ms | 44088 KB | Output is correct |
64 | Correct | 772 ms | 44376 KB | Output is correct |
65 | Correct | 745 ms | 44376 KB | Output is correct |
66 | Correct | 759 ms | 44436 KB | Output is correct |
67 | Correct | 694 ms | 44340 KB | Output is correct |
68 | Correct | 744 ms | 44360 KB | Output is correct |
69 | Correct | 677 ms | 44376 KB | Output is correct |
70 | Correct | 84 ms | 9200 KB | Output is correct |
71 | Correct | 86 ms | 9224 KB | Output is correct |
72 | Correct | 80 ms | 9168 KB | Output is correct |
73 | Correct | 81 ms | 9324 KB | Output is correct |
74 | Correct | 79 ms | 9200 KB | Output is correct |
75 | Correct | 87 ms | 9164 KB | Output is correct |
76 | Correct | 89 ms | 9164 KB | Output is correct |
77 | Correct | 80 ms | 9216 KB | Output is correct |
78 | Correct | 80 ms | 9144 KB | Output is correct |
79 | Correct | 79 ms | 9168 KB | Output is correct |
80 | Correct | 77 ms | 9192 KB | Output is correct |
81 | Correct | 79 ms | 9224 KB | Output is correct |
82 | Correct | 91 ms | 9164 KB | Output is correct |
83 | Correct | 84 ms | 9212 KB | Output is correct |
84 | Correct | 79 ms | 9200 KB | Output is correct |
85 | Correct | 79 ms | 9220 KB | Output is correct |
86 | Correct | 83 ms | 9220 KB | Output is correct |
87 | Correct | 113 ms | 9216 KB | Output is correct |
88 | Correct | 92 ms | 9168 KB | Output is correct |
89 | Correct | 82 ms | 9124 KB | Output is correct |
90 | Correct | 78 ms | 9100 KB | Output is correct |