제출 #598203

#제출 시각아이디문제언어결과실행 시간메모리
598203AsymmetryDango Maker (JOI18_dango_maker)C++17
33 / 100
191 ms262144 KiB
#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 t(n + 6, vector (m + 6, 'a')); vector dp(n + 6, vector (m + 6, vector (2, 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][0] = max(dp[x][y][0], max(dp[x - 1][y + 1][0], dp[x - 3][y + 3][1]) + 1); } if (canDown(x, y)) { dp[x][y][1] = max(dp[x][y][1], max(dp[x - 1][y + 1][0], dp[x - 1][y + 1][1]) + 1); } } } int odp = 0; FOR (x, 3, n + 2) { odp += max(dp[x][3][0], dp[x][3][1]); } FOR (y, 4, m + 2) { odp += max(dp[n + 2][y][0], dp[n + 2][y][1]); } cout << odp << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...