Submission #914956

#TimeUsernameProblemLanguageResultExecution timeMemory
914956HorizonWestDango Maker (JOI18_dango_maker)C++17
100 / 100
1489 ms18800 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define db double #define ll __int128 #define int long long #define pb push_back #define fs first #define sd second #define Mod long(1e9 + 7) #define all(x) x.begin(), x.end() #define unvisited long(-1) #define Eps double(1e-9) #define _for(i, n) for(int i = 0; i < (n); i++) #define dbg(x) cout << #x ": " << x << endl; const int Max = (1LL << 32), Inf = 1e9 + 7; void print(bool x) { cout << (x ? "YES" : "NO") << endl; } string tostring (ll x) { string ans = ""; while(x > 0) { ans += (x % 10 + '0'); x /= 10; } reverse(all(ans)); return ans; } void solve() { int n, m, ans = 0; cin >> n >> m; vector <vector<char>> v(n, vector <char> (m, 0)); for(auto& u : v) for(auto& t : u) cin >> t; for(int i = 1; i < n+m; i++) { vector <vector<int>> dp(n+7, vector <int> (3, 0)); vector <vector<char>> s(n+7, vector <char> (3, '.')); for(int j = 0; j < n; j++) { for(int k = 0; k < 3; k++) { int x = j, y = i - j + k - 1; if(x < 0 || x > n - 1 || y < 0 || y > m - 1) continue; s[j][k] = v[x][y]; } } for(int j = 0; j <= n+3; j++) { for(int k = 0; k < 3; k++) { dp[j+1][0] = max(dp[j+1][0], dp[j][k]); if(s[j][0] == 'R' && s[j][1] == 'G' && s[j][2] == 'W') dp[j+1][1] = max(dp[j][0], dp[j][1]) + 1; if(j != 0) { if(s[j-1][0] == 'R' && s[j][1] == 'G' && s[j+1][2] == 'W') dp[j+1][2] = max(dp[j][2], dp[j][0]) + 1; } } } ans += dp[n+3][0]; } cout << ans << endl; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int Q = 1; //cin >> Q; while (Q--) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...