Submission #156525

#TimeUsernameProblemLanguageResultExecution timeMemory
156525staniewzkiDango Maker (JOI18_dango_maker)C++14
100 / 100
518 ms47124 KiB
#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 (stderr)

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);
               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...