Submission #126633

#TimeUsernameProblemLanguageResultExecution timeMemory
126633EntityITDango Maker (JOI18_dango_maker)C++14
100 / 100
644 ms18172 KiB
/* check for(ij) */ #include<bits/stdc++.h> using namespace std; const int N = (int)3e3 + 5; int n, m, ans, dp[N][4]; char c[N][N]; bool validCell (int x, int y) { return x >= 1 && y >= 1 && x <= n && y <= m; } bool downCheck (int x, int y) { return validCell(x, y) && validCell(x + 1, y) && validCell(x + 2, y) && c[x][y] == 'R' && c[x + 1][y] == 'G' && c[x + 2][y] == 'W'; } bool rightCheck (int x, int y) { return validCell(x, y) && validCell(x, y + 1) && validCell(x, y + 2) && c[x][y] == 'R' && c[x][y + 1] == 'G' && c[x][y + 2] == 'W'; } void update (int &_a, int _b) { _a = max(_a, _b); } int main () { // freopen("test.INP", "r", stdin); // freopen("Seeht.OUT", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) cin >> c[i][j]; } for (int ij = 2; ij <= n + m - 2; ++ij) { memset(dp, 0, sizeof dp); for (int i = max(1, ij - m); i <= min(n, ij - 1); ++i) { int j = ij - i; for (int mask = 0; mask < 4; ++mask) { update(dp[i][mask >> 1], dp[i - 1][mask]); if (downCheck(i, j) ) update(dp[i][(mask >> 1) | 2], dp[i - 1][mask] + 1); } if (rightCheck(i, j) ) update(dp[i][0], dp[i - 1][0] + 1); } ans += max(dp[ min(n, ij - 1) ][0], max(dp[ min(n, ij - 1) ][1], max(dp[ min(n, ij - 1) ][2], dp[ min(n, ij - 1) ][3]) ) ); } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...