Submission #598204

# Submission time Handle Problem Language Result Execution time Memory
598204 2022-07-17T19:32:42 Z Asymmetry Dango Maker (JOI18_dango_maker) C++17
100 / 100
260 ms 88960 KB
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
#define FOR(i,l,r) for(int i=(l);i<=(r);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define ssize(x) int(x.size())
template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';}
template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';}
#ifdef DEBUG
#define debug(x...) cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...)<<'\n';}(x)
#else
#define debug(...) {}
#endif

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	vector<vector<char>> t(n + 6, vector<char> (m + 6, 'a'));
	vector<vector<pair<int, int>>> dp(n + 6, vector<pair<int, int>> (m + 6, {0, 0}));
	FOR (i, 3, n + 2) {
		FOR (j, 3, m + 2) {
			cin >> t[i][j];
		}
	}
	
	auto canRight = [&](int x, int y) {
		return (t[x][y] == 'R') && (t[x][y + 1] == 'G') && (t[x][y + 2] == 'W');
	};

	auto canDown = [&](int x, int y) {
		return (t[x][y] == 'R') && (t[x + 1][y] == 'G') && (t[x + 2][y] == 'W');
	};
	
	FOR (x, 3, n + 2) {
		FOR (y, 3, m + 2) {
			dp[x][y] = dp[x - 1][y + 1];
			if (canRight(x, y)) {
				dp[x][y].first = max(dp[x][y].first, max(dp[x - 1][y + 1].first, dp[x - 3][y + 3].second) + 1);
			}
			if (canDown(x, y)) {
				dp[x][y].second = max(dp[x][y].second, max(dp[x - 1][y + 1].first, dp[x - 1][y + 1].second) + 1);
			}
		}
	}

	int odp = 0;

	FOR (x, 3, n + 2) {
		odp += max(dp[x][3].first, dp[x][3].second);
	}
	FOR (y, 4, m + 2) {
		odp += max(dp[n + 2][y].first, dp[n + 2][y].second);
	}

	cout << odp << endl;
}
# 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 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 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 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 316 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 256 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 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 316 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 1 ms 212 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 256 KB Output is correct
54 Correct 1 ms 468 KB Output is correct
55 Correct 1 ms 724 KB Output is correct
56 Correct 2 ms 596 KB Output is correct
57 Correct 1 ms 716 KB Output is correct
58 Correct 29 ms 9556 KB Output is correct
59 Correct 234 ms 88884 KB Output is correct
60 Correct 235 ms 88960 KB Output is correct
61 Correct 260 ms 88956 KB Output is correct
62 Correct 1 ms 468 KB Output is correct
63 Correct 227 ms 85976 KB Output is correct
64 Correct 187 ms 88952 KB Output is correct
65 Correct 186 ms 88840 KB Output is correct
66 Correct 174 ms 88856 KB Output is correct
67 Correct 208 ms 88952 KB Output is correct
68 Correct 185 ms 88952 KB Output is correct
69 Correct 173 ms 88840 KB Output is correct
70 Correct 22 ms 10196 KB Output is correct
71 Correct 22 ms 10284 KB Output is correct
72 Correct 23 ms 10196 KB Output is correct
73 Correct 25 ms 10200 KB Output is correct
74 Correct 22 ms 10208 KB Output is correct
75 Correct 23 ms 10200 KB Output is correct
76 Correct 21 ms 10192 KB Output is correct
77 Correct 26 ms 10196 KB Output is correct
78 Correct 20 ms 10208 KB Output is correct
79 Correct 21 ms 10204 KB Output is correct
80 Correct 22 ms 10184 KB Output is correct
81 Correct 20 ms 10192 KB Output is correct
82 Correct 21 ms 10196 KB Output is correct
83 Correct 20 ms 10204 KB Output is correct
84 Correct 19 ms 10192 KB Output is correct
85 Correct 25 ms 10284 KB Output is correct
86 Correct 22 ms 10204 KB Output is correct
87 Correct 19 ms 10292 KB Output is correct
88 Correct 22 ms 10196 KB Output is correct
89 Correct 23 ms 10188 KB Output is correct
90 Correct 21 ms 10196 KB Output is correct