Submission #1289719

#TimeUsernameProblemLanguageResultExecution timeMemory
1289719opituDango Maker (JOI18_dango_maker)C++20
100 / 100
259 ms11976 KiB
#pragma GCC target("tune=native") #pragma GCC optimize("O3,inline,unroll-loops") #include <bits/stdc++.h> #define int long long #define iamaperson int main() {\ preprocess();\ int t = 1; while (t--) solve();\ } using namespace std; void preprocess() {} // just in case!!!!1 int n, m; bool cc(vector<string> &g, int i, int j, char c) { return 0 <= i && i < n && 0 <= j && j < m && g[i][j] == c; } bool cv(vector<string> &g, int i, int j) { return cc(g, i-1, j, 'R') && cc(g, i, j, 'G') && cc(g, i+1, j, 'W'); } bool ch(vector<string> &g, int i, int j) { return cc(g, i, j-1, 'R') && cc(g, i, j, 'G') && cc(g, i, j+1, 'W'); } void solve() { cin >> n >> m; vector<string> g(n); for (auto &x : g) cin >> x; vector<int[3]> dp(n+m+1); int ans = 0; for (int x = 0; x < n+m; ++x) { for (int i = 0; i <= x; ++i) { dp[i+1][0] = max({dp[i][0], dp[i][1], dp[i][2]}); dp[i+1][1] = max(dp[i][0], dp[i][1]) + cv(g, i, x-i); dp[i+1][2] = max(dp[i][0], dp[i][2]) + ch(g, i, x-i); } ans += max({dp[x+1][0], dp[x+1][1], dp[x+1][2]}); } cout << ans; } #undef int iamaperson
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...