Submission #503234

#TimeUsernameProblemLanguageResultExecution timeMemory
503234Kirill_MaglyshDango Maker (JOI18_dango_maker)C++17
0 / 100
185 ms262148 KiB
#include <iostream> #include <vector> #include <set> #include <map> #include <algorithm> #define printLn(n) cout << n << '\n' using namespace std; short item = 0; vector<vector<char>> field(3000 + 2, vector<char>(3000 + 2, '#')); vector<vector<vector<short>>> dp(3000 + 2, vector<vector<short>>(3000 + 2, vector<short>(3, item))); const short EMPTY = 0; const short HORIZONTAL = 1; const short VERTICAL = 2; short readLL(); string readStr(); void resolve(); int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); resolve(); return 0; } void resolve() { short height = readLL(); short width = readLL(); for (short i = 1; i <= height; ++i) { string str = readStr(); for (short j = 1; j <= width; ++j) { field[i][j] = str[j - 1]; } } 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])); } } } printLn(res); } short readLL() { short num; cin >> num; return num; } string readStr() { string num; cin >> num; return num; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...