Submission #206422

#TimeUsernameProblemLanguageResultExecution timeMemory
206422E869120Dango Maker (JOI18_dango_maker)C++14
33 / 100
2072 ms19064 KiB
#include <string> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { cin.tie(0); ios_base::sync_with_stdio(false); int H, W; cin >> H >> W; vector<string> S(H); for (int i = 0; i < H; ++i) { cin >> S[i]; } int ans = 0; for (int i = 0; i <= H + W - 4; ++i) { vector<int> seq(2 * H); for (int j = 0; j < H; ++j) { int x = j, y = i - j; if (y < 0 || y >= W) continue; if (x <= H - 3 && S[x][y] == 'R' && S[x + 1][y] == 'G' && S[x + 2][y] == 'W') { seq[(H - x - 1) * 2 - 1] = 1; } if (y <= W - 3 && S[x][y] == 'R' && S[x][y + 1] == 'G' && S[x][y + 2] == 'W') { seq[(H - x - 1) * 2] = 1; } } vector<int> dp(8); for (int j = 0; j < 2 * H; ++j) { vector<int> ndp(8); for (int k = 0; k < 8; ++k) { ndp[(k << 1) & 7] = max(ndp[(k << 1) & 7], dp[k]); if (seq[j] == 1 && !(k & 1) && (j % 2 == 0 || !(k & 4))) { ndp[((k << 1) | 1) & 7] = max(ndp[((k << 1) | 1) & 7], dp[k] + 1); } } dp = ndp; } ans += *max_element(dp.begin(), dp.end()); } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...