Submission #41076

#TimeUsernameProblemLanguageResultExecution timeMemory
41076kdh9949Dango Maker (JOI18_dango_maker)C++14
100 / 100
633 ms150768 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3005; int n, m, d[N][N][4], r; char a[N][N]; int v(int x, int y, int d){ return a[x][y] == 'R' && a[x + d][y + !d] == 'G' && a[x + 2 * d][y + 2 * !d] == 'W'; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m; for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) cin >> a[i][j]; for(int t = 2; t <= n + m; t++){ int cm = 0; for(int i = t - 1, j; i >= 1; i--){ j = t - i; if(j < 1 || j > m || i < 1 || i > n) continue; int *c = d[i][j], *p = d[i + 1][j - 1]; c[0] = max(p[0] + v(i, j, 1), p[1]); c[1] = max(p[2], p[3]); if(v(i, j, 0)){ c[2] = max(p[0], p[1]) + 1; c[3] = max(p[2], p[3]) + 1; } cm = max(cm, *max_element(c, c + 4)); } r += cm; } cout << r; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...