Submission #503239

#TimeUsernameProblemLanguageResultExecution timeMemory
503239Kirill_MaglyshDango Maker (JOI18_dango_maker)C++17
100 / 100
256 ms70836 KiB
#include <iostream> #include <vector> #include <set> #include <map> #include <algorithm> using namespace std; char field[3000 + 2][3000 + 2]; short dp[3000 + 2][3000 + 2][3]; const short EMPTY = 0; const short HORIZONTAL = 1; const short VERTICAL = 2; void resolve(); int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); resolve(); return 0; } void resolve() { short height; short width; cin >> height >> width; for (short i = 1; i <= height; ++i) { for (short j = 1; j <= width; ++j) { cin >> field[i][j]; } } int res = 0; for (short i = 1; i <= height; ++i) { for (short j = 1; j <= width; ++j) { dp[i][j][EMPTY] = max(dp[i - 1][j + 1][EMPTY], max(dp[i - 1][j + 1][HORIZONTAL], dp[i - 1][j + 1][VERTICAL])); if (field[i - 1][j] == 'R' && field[i][j] == 'G' && field[i + 1][j] == 'W') { dp[i][j][VERTICAL] = 1 + max(dp[i - 1][j + 1][VERTICAL], dp[i - 1][j + 1][EMPTY]); } if (field[i][j - 1] == 'R' && field[i][j] == 'G' && field[i][j + 1] == 'W') { dp[i][j][HORIZONTAL] = 1 + max(dp[i - 1][j + 1][HORIZONTAL], dp[i - 1][j + 1][EMPTY]); } if (i == height || j == 1) { res += max(dp[i][j][EMPTY], max(dp[i][j][HORIZONTAL], dp[i][j][VERTICAL])); } } } cout << res << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...