# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
300456 | 2020-09-17T07:29:59 Z | CSQ31 | Dango Maker (JOI18_dango_maker) | C++14 | 234 ms | 18168 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pi; const int MAXN = 3005; int n, m; char str[MAXN][MAXN]; int R[MAXN], W[MAXN]; int dR[MAXN], dW[MAXN]; int solve(int n){ for(int i=1; i<=n; i++){ dR[i] = dR[i-1]; dW[i] = dW[i-1]; if(i > 1){ dR[i] = max(dR[i], dW[i-2]); dW[i] = max(dW[i], dR[i-2]); } if(R[i-1] && W[i]) dR[i]++; if(W[i-1] && R[i]) dW[i]++; } return max(dR[n], dW[n]); } bool okR(int x, int y){ return x >= 0 && x < n && y >= 0 && y < m && str[x][y] == 'R'; } bool okW(int x, int y){ return x >= 0 && x < n && y >= 0 && y < m && str[x][y] == 'W'; } bool okG(int x, int y){ return x >= 0 && x < n && y >= 0 && y < m && str[x][y] == 'G'; } int main(){ scanf("%d %d",&n,&m); for(int i=0; i<n; i++) scanf("%s", str[i]); int ans = 0; for(int i=0; i<n+m-1; i++){ vector<pi> v; for(int j=0; j<=i; j++){ if(okG(j, i-j)) v.push_back(pi(j, i-j)); } for(int i=0; i<v.size(); ){ int e = i; while(e < v.size() && v[e].first - v[i].first == e - i) e++; R[0] = okR(v[i].first - 1, v[i].second); W[0] = okW(v[i].first, v[i].second + 1); for(int j=i; j<e; j++){ R[j-i+1] = okR(v[j].first, v[j].second-1); W[j-i+1] = okW(v[j].first + 1, v[j].second); } ans += solve(e - i); i = e; } } cout << ans << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 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 | 384 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 | 1 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 | 1 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 | 1 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 | 384 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 | 1 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 | 1 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 | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 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 | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 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 | 384 KB | Output is correct |
34 | Correct | 1 ms | 416 KB | Output is correct |
35 | Correct | 1 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 | 1 ms | 384 KB | Output is correct |
47 | Correct | 1 ms | 384 KB | Output is correct |
48 | Correct | 1 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 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 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 | 384 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 | 1 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 | 1 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 | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 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 | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 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 | 384 KB | Output is correct |
34 | Correct | 1 ms | 416 KB | Output is correct |
35 | Correct | 1 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 | 1 ms | 384 KB | Output is correct |
47 | Correct | 1 ms | 384 KB | Output is correct |
48 | Correct | 1 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 | 9 ms | 9216 KB | Output is correct |
56 | Correct | 3 ms | 384 KB | Output is correct |
57 | Correct | 6 ms | 6272 KB | Output is correct |
58 | Correct | 24 ms | 4224 KB | Output is correct |
59 | Correct | 233 ms | 18132 KB | Output is correct |
60 | Correct | 234 ms | 18168 KB | Output is correct |
61 | Correct | 232 ms | 18040 KB | Output is correct |
62 | Correct | 3 ms | 384 KB | Output is correct |
63 | Correct | 226 ms | 17656 KB | Output is correct |
64 | Correct | 160 ms | 18168 KB | Output is correct |
65 | Correct | 160 ms | 18168 KB | Output is correct |
66 | Correct | 163 ms | 18168 KB | Output is correct |
67 | Correct | 208 ms | 18040 KB | Output is correct |
68 | Correct | 216 ms | 18040 KB | Output is correct |
69 | Correct | 207 ms | 18044 KB | Output is correct |
70 | Correct | 16 ms | 4352 KB | Output is correct |
71 | Correct | 15 ms | 4352 KB | Output is correct |
72 | Correct | 15 ms | 4352 KB | Output is correct |
73 | Correct | 15 ms | 4352 KB | Output is correct |
74 | Correct | 15 ms | 4352 KB | Output is correct |
75 | Correct | 15 ms | 4352 KB | Output is correct |
76 | Correct | 15 ms | 4352 KB | Output is correct |
77 | Correct | 15 ms | 4352 KB | Output is correct |
78 | Correct | 15 ms | 4352 KB | Output is correct |
79 | Correct | 15 ms | 4352 KB | Output is correct |
80 | Correct | 15 ms | 4224 KB | Output is correct |
81 | Correct | 15 ms | 4352 KB | Output is correct |
82 | Correct | 15 ms | 4352 KB | Output is correct |
83 | Correct | 15 ms | 4352 KB | Output is correct |
84 | Correct | 15 ms | 4352 KB | Output is correct |
85 | Correct | 15 ms | 4352 KB | Output is correct |
86 | Correct | 15 ms | 4352 KB | Output is correct |
87 | Correct | 15 ms | 4352 KB | Output is correct |
88 | Correct | 15 ms | 4352 KB | Output is correct |
89 | Correct | 15 ms | 4352 KB | Output is correct |
90 | Correct | 15 ms | 4352 KB | Output is correct |