# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
486778 | 2021-11-12T18:29:43 Z | socho | Dango Maker (JOI18_dango_maker) | C++14 | 422 ms | 79812 KB |
/* Going for full */ #include <bits/stdc++.h> using namespace std; void fast() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } void ran() { srand(chrono::steady_clock::now().time_since_epoch().count()); } long long get_rand() { long long a = rand(); long long b = rand(); return a * (RAND_MAX + 1ll) + b; } void usaco() { freopen("problem.in", "r", stdin); freopen("problem.out", "w", stdout); } template<typename T> using min_pq = priority_queue<T, vector<T>, greater<T>>; #define endl '\n' // #define double long double // #define int long long // const int MOD = 1000 * 1000 * 1000 + 7; // const int MOD = 998244353; // #define cerr if(0) cerr #define debug(x) cerr << #x << ": " << x << endl; const int MXN = 3005; int n, m; int grid[MXN][MXN]; int can[MXN][MXN]; int dp[MXN][3]; signed main() { cin >> n >> m; for (int i=1; i<=n; i++) { string s; cin >> s; for (int j=1; j<=m; j++) { if (s[j-1] == 'R') grid[i][j] = 1; if (s[j-1] == 'G') grid[i][j] = 2; if (s[j-1] == 'W') grid[i][j] = 3; } } for (int i=1; i<=n; i++) { for (int j=1; j<=m; j++) { if (grid[i][j] == 2) { if (grid[i-1][j] == 1 && grid[i+1][j] == 3) { can[i][j] += 1; } if (grid[i][j-1] == 1 && grid[i][j+1] == 3) { can[i][j] += 2; } } } } int ans = 0; for (int diag=2; diag<=n+m; diag++) { dp[0][0] = dp[0][1] = dp[0][2] = 0; int here = 0; vector<int> vc; vc.push_back(-1); for (int i=1; i<=n; i++) { int j = diag - i; if (j >= 1 && j <= m) { vc.push_back(can[i][j]); } } for (int i=1; i<vc.size(); i++) { dp[i][0] = dp[i][1] = dp[i][2] = 0; dp[i][0] = max(max(dp[i-1][0], dp[i-1][1]), dp[i-1][2]); if (vc[i] & 1) { dp[i][1] = max(dp[i][1], 1 + max(dp[i-1][0], dp[i-1][1])); } if (vc[i] & 2) { dp[i][2] = max(dp[i][2], 1 + max(dp[i-1][0], dp[i-1][2])); } here = max(here, max(max(dp[i][0], dp[i][1]), dp[i][2])); } ans += here; } cout << ans << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 296 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 332 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 296 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 332 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 0 ms | 332 KB | Output is correct |
18 | Correct | 0 ms | 332 KB | Output is correct |
19 | Correct | 0 ms | 332 KB | Output is correct |
20 | Correct | 0 ms | 332 KB | Output is correct |
21 | Correct | 0 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 0 ms | 332 KB | Output is correct |
24 | Correct | 0 ms | 332 KB | Output is correct |
25 | Correct | 0 ms | 332 KB | Output is correct |
26 | Correct | 0 ms | 204 KB | Output is correct |
27 | Correct | 1 ms | 332 KB | Output is correct |
28 | Correct | 0 ms | 332 KB | Output is correct |
29 | Correct | 0 ms | 332 KB | Output is correct |
30 | Correct | 1 ms | 332 KB | Output is correct |
31 | Correct | 0 ms | 296 KB | Output is correct |
32 | Correct | 0 ms | 332 KB | Output is correct |
33 | Correct | 0 ms | 332 KB | Output is correct |
34 | Correct | 0 ms | 332 KB | Output is correct |
35 | Correct | 0 ms | 332 KB | Output is correct |
36 | Correct | 1 ms | 332 KB | Output is correct |
37 | Correct | 1 ms | 332 KB | Output is correct |
38 | Correct | 1 ms | 332 KB | Output is correct |
39 | Correct | 1 ms | 332 KB | Output is correct |
40 | Correct | 0 ms | 332 KB | Output is correct |
41 | Correct | 0 ms | 332 KB | Output is correct |
42 | Correct | 0 ms | 332 KB | Output is correct |
43 | Correct | 0 ms | 332 KB | Output is correct |
44 | Correct | 0 ms | 332 KB | Output is correct |
45 | Correct | 1 ms | 332 KB | Output is correct |
46 | Correct | 0 ms | 332 KB | Output is correct |
47 | Correct | 0 ms | 332 KB | Output is correct |
48 | Correct | 0 ms | 332 KB | Output is correct |
49 | Correct | 1 ms | 304 KB | Output is correct |
50 | Correct | 0 ms | 332 KB | Output is correct |
51 | Correct | 0 ms | 332 KB | Output is correct |
52 | Correct | 0 ms | 332 KB | Output is correct |
53 | Correct | 1 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 296 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 332 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 204 KB | Output is correct |
17 | Correct | 0 ms | 332 KB | Output is correct |
18 | Correct | 0 ms | 332 KB | Output is correct |
19 | Correct | 0 ms | 332 KB | Output is correct |
20 | Correct | 0 ms | 332 KB | Output is correct |
21 | Correct | 0 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 0 ms | 332 KB | Output is correct |
24 | Correct | 0 ms | 332 KB | Output is correct |
25 | Correct | 0 ms | 332 KB | Output is correct |
26 | Correct | 0 ms | 204 KB | Output is correct |
27 | Correct | 1 ms | 332 KB | Output is correct |
28 | Correct | 0 ms | 332 KB | Output is correct |
29 | Correct | 0 ms | 332 KB | Output is correct |
30 | Correct | 1 ms | 332 KB | Output is correct |
31 | Correct | 0 ms | 296 KB | Output is correct |
32 | Correct | 0 ms | 332 KB | Output is correct |
33 | Correct | 0 ms | 332 KB | Output is correct |
34 | Correct | 0 ms | 332 KB | Output is correct |
35 | Correct | 0 ms | 332 KB | Output is correct |
36 | Correct | 1 ms | 332 KB | Output is correct |
37 | Correct | 1 ms | 332 KB | Output is correct |
38 | Correct | 1 ms | 332 KB | Output is correct |
39 | Correct | 1 ms | 332 KB | Output is correct |
40 | Correct | 0 ms | 332 KB | Output is correct |
41 | Correct | 0 ms | 332 KB | Output is correct |
42 | Correct | 0 ms | 332 KB | Output is correct |
43 | Correct | 0 ms | 332 KB | Output is correct |
44 | Correct | 0 ms | 332 KB | Output is correct |
45 | Correct | 1 ms | 332 KB | Output is correct |
46 | Correct | 0 ms | 332 KB | Output is correct |
47 | Correct | 0 ms | 332 KB | Output is correct |
48 | Correct | 0 ms | 332 KB | Output is correct |
49 | Correct | 1 ms | 304 KB | Output is correct |
50 | Correct | 0 ms | 332 KB | Output is correct |
51 | Correct | 0 ms | 332 KB | Output is correct |
52 | Correct | 0 ms | 332 KB | Output is correct |
53 | Correct | 1 ms | 332 KB | Output is correct |
54 | Correct | 1 ms | 332 KB | Output is correct |
55 | Correct | 12 ms | 12748 KB | Output is correct |
56 | Correct | 1 ms | 332 KB | Output is correct |
57 | Correct | 10 ms | 15448 KB | Output is correct |
58 | Correct | 49 ms | 16956 KB | Output is correct |
59 | Correct | 419 ms | 79676 KB | Output is correct |
60 | Correct | 422 ms | 79752 KB | Output is correct |
61 | Correct | 389 ms | 79708 KB | Output is correct |
62 | Correct | 1 ms | 332 KB | Output is correct |
63 | Correct | 380 ms | 79336 KB | Output is correct |
64 | Correct | 322 ms | 79792 KB | Output is correct |
65 | Correct | 317 ms | 79812 KB | Output is correct |
66 | Correct | 285 ms | 79616 KB | Output is correct |
67 | Correct | 307 ms | 60192 KB | Output is correct |
68 | Correct | 303 ms | 60272 KB | Output is correct |
69 | Correct | 322 ms | 65856 KB | Output is correct |
70 | Correct | 37 ms | 17092 KB | Output is correct |
71 | Correct | 39 ms | 17224 KB | Output is correct |
72 | Correct | 39 ms | 17172 KB | Output is correct |
73 | Correct | 37 ms | 16996 KB | Output is correct |
74 | Correct | 37 ms | 17044 KB | Output is correct |
75 | Correct | 37 ms | 17120 KB | Output is correct |
76 | Correct | 39 ms | 16992 KB | Output is correct |
77 | Correct | 36 ms | 17092 KB | Output is correct |
78 | Correct | 37 ms | 17020 KB | Output is correct |
79 | Correct | 39 ms | 17096 KB | Output is correct |
80 | Correct | 38 ms | 17172 KB | Output is correct |
81 | Correct | 49 ms | 17040 KB | Output is correct |
82 | Correct | 37 ms | 17092 KB | Output is correct |
83 | Correct | 36 ms | 17040 KB | Output is correct |
84 | Correct | 36 ms | 17080 KB | Output is correct |
85 | Correct | 37 ms | 17100 KB | Output is correct |
86 | Correct | 37 ms | 17008 KB | Output is correct |
87 | Correct | 36 ms | 17100 KB | Output is correct |
88 | Correct | 36 ms | 17100 KB | Output is correct |
89 | Correct | 37 ms | 17076 KB | Output is correct |
90 | Correct | 40 ms | 17004 KB | Output is correct |