답안 #156525

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
156525 2019-10-06T10:39:55 Z staniewzki Dango Maker (JOI18_dango_maker) C++14
100 / 100
518 ms 47124 KB
#include<bits/stdc++.h>
using namespace std;

ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }

using LL = long long;
using PII = pair<int, int>;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n, m;
	cin >> n >> m;

	map<char, int> id = {{'R', 1}, {'G', 2}, {'W', 3}};
	vector<vector<int>> a(n, vector<int>(m));
	REP(i, n) REP(j, m) {
		char c;
		cin >> c;
		a[i][j] = id[c];
	}

	vector<vector<bool>> v(n, vector<bool>(m));
	vector<vector<bool>> h(n, vector<bool>(m));
	FOR(i, 1, n - 2) REP(j, m) {
		if(a[i][j] != 2) continue;
		if(a[i - 1][j] == 1 && a[i + 1][j] == 3)
			v[i][j] = true;
	}

	REP(i, n) FOR(j, 1, m - 2) {
		if(a[i][j] != 2) continue;
		if(a[i][j - 1] == 1 && a[i][j + 1] == 3)
			h[i][j] = true;
	}

	int ans = 0;
	FOR(s, 0, n + m - 2) {
		int j = min(m - 1, s);
		int i = s - j;
		array<int, 2> dp = {0, 0}; 
		while(0 <= j && i < n) {
			auto nxt = dp;
			for(int &q : nxt) q = max(nxt[0], nxt[1]);
			debug(i, j);
			if(v[i][j]) nxt[1] = max(nxt[1], dp[1] + 1);
			if(h[i][j]) nxt[0] = max(nxt[0], dp[0] + 1);
			j--, i++;
			dp = nxt;
		}
		debug(s, dp);
		ans += max(dp[0], dp[1]);
	}

	cout << ans << "\n";
}

Compilation message

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:79:15: warning: statement has no effect [-Wunused-value]
    debug(i, j);
               ^
dango_maker.cpp:85:15: warning: statement has no effect [-Wunused-value]
   debug(s, dp);
               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 416 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 392 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 2 ms 376 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 2 ms 376 KB Output is correct
53 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 2 ms 416 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 392 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 2 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 2 ms 376 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 2 ms 376 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 2 ms 376 KB Output is correct
48 Correct 2 ms 376 KB Output is correct
49 Correct 2 ms 376 KB Output is correct
50 Correct 2 ms 376 KB Output is correct
51 Correct 2 ms 376 KB Output is correct
52 Correct 2 ms 376 KB Output is correct
53 Correct 2 ms 376 KB Output is correct
54 Correct 2 ms 376 KB Output is correct
55 Correct 3 ms 888 KB Output is correct
56 Correct 3 ms 376 KB Output is correct
57 Correct 4 ms 812 KB Output is correct
58 Correct 57 ms 5700 KB Output is correct
59 Correct 518 ms 47124 KB Output is correct
60 Correct 513 ms 46976 KB Output is correct
61 Correct 506 ms 46980 KB Output is correct
62 Correct 2 ms 376 KB Output is correct
63 Correct 514 ms 45424 KB Output is correct
64 Correct 325 ms 46988 KB Output is correct
65 Correct 326 ms 47096 KB Output is correct
66 Correct 333 ms 47112 KB Output is correct
67 Correct 317 ms 47112 KB Output is correct
68 Correct 310 ms 47100 KB Output is correct
69 Correct 325 ms 47096 KB Output is correct
70 Correct 34 ms 5752 KB Output is correct
71 Correct 33 ms 5624 KB Output is correct
72 Correct 33 ms 5596 KB Output is correct
73 Correct 33 ms 5624 KB Output is correct
74 Correct 34 ms 5624 KB Output is correct
75 Correct 41 ms 5624 KB Output is correct
76 Correct 33 ms 5752 KB Output is correct
77 Correct 34 ms 5668 KB Output is correct
78 Correct 33 ms 5624 KB Output is correct
79 Correct 33 ms 5624 KB Output is correct
80 Correct 34 ms 5624 KB Output is correct
81 Correct 33 ms 5596 KB Output is correct
82 Correct 34 ms 5624 KB Output is correct
83 Correct 34 ms 5600 KB Output is correct
84 Correct 34 ms 5624 KB Output is correct
85 Correct 33 ms 5628 KB Output is correct
86 Correct 34 ms 5752 KB Output is correct
87 Correct 34 ms 5624 KB Output is correct
88 Correct 33 ms 5624 KB Output is correct
89 Correct 34 ms 5604 KB Output is correct
90 Correct 37 ms 5624 KB Output is correct