This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
int n, m, dp[6010][3], sum, x, y, cnt;
char c[3010][3010];
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) cin >> c[i][j];
for (int i = 1; i <= 6; i++) {
x = i; y = 1; cnt = 0;
while ((x >= 1) && (y <= m)) {
++cnt;
dp[cnt][0] = max(dp[cnt-1][0],max(dp[cnt-1][1],dp[cnt-1][2]));
if ((x <= n) && (c[x][y] == 'G')) {
if ((c[x-1][y] == 'R') && (c[x+1][y] == 'W')) dp[cnt][1] = max(dp[cnt-1][0],dp[cnt-1][1])+1;
else dp[cnt][1] = 0;
if ((c[x][y-1] == 'R') && (c[x][y+1] == 'W')) dp[cnt][2] = max(dp[cnt-1][0],dp[cnt-1][2])+1;
else dp[cnt][2] = 0;
} else dp[cnt][1] = dp[cnt][2] = 0;
x--; y++;
}
sum += max(dp[cnt][0],max(dp[cnt][1],dp[cnt][2]));
}
cout << sum << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |