Submission #815455

#TimeUsernameProblemLanguageResultExecution timeMemory
815455vjudge1Dango Maker (JOI18_dango_maker)C++17
0 / 100
1 ms324 KiB
#include <bits/stdc++.h> using namespace std; int N, M; vector<vector<char>> board; int f(const int& i, const int& j, const int& k) { if (k == 1) return board[i - 1][j] == 'R' && board[i][j] == 'G' && board[i + 1][j] == 'W'; if (k == 2) return board[i][j - 1] == 'R' && board[i][j] == 'G' && board[i][j + 1] == 'W'; return false; } int main() { // freopen("inp.txt", "r", stdin); ios::sync_with_stdio(false); cin >> N >> M; board.resize(N + 2, vector<char>(M + 2)); for (int i = 1; i <= N; i++) for (int j = 1; j <= M; j++) cin >> board[i][j]; int result = 0; for (int d = 2; d <= N + M; d++) { vector<vector<int>> dp(M + 1, vector<int>(3)); int temp = 0; for (int j = 1; j <= M; j++) { int i = d - j; if (i < 1 || N < i) continue; dp[j][0] = max({dp[j - 1][0], dp[j - 1][1], dp[j - 1][2]}); dp[j][1] = max(dp[j - 1][0], dp[j - 1][2]) + f(i, j, 1); dp[j][2] = max(dp[j - 1][0], dp[j - 1][1]) + f(i, j, 2); temp = max({dp[j][0], dp[j][1], dp[j][2]}); } result += temp; } cout << result; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...