# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170449 | Akashi | Dango Maker (JOI18_dango_maker) | C++14 | 235 ms | 18164 KiB |
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 <bits/stdc++.h>
using namespace std;
int n, m;
int d[3010][2][2];
char s[3010][3010];
int main()
{
scanf("%d%d", &n, &m);
for(int i = 1; i <= n ; ++i) scanf("%s", s[i] + 1);
int ans = 0;
for(int diag = 1; diag <= n + m - 1 ; ++diag){
int l, c;
l = 1; c = diag;
if(c > m) l = l + (c - m), c = m;
if(l > n) c = c + (l - n), l = n;
int L = min(n - l + 1, c);
for(int i = 1; i <= L ; ++i)
for(int j = 0; j < 2 ; ++j)
for(int t = 0; t < 2 ; ++t)
d[i][j][t] = 0;
for(int i = 1; i <= L ; ++i, ++l, --c){
for(int j = 0; j < 2 ; ++j)
for(int t = 0; t < 2 ; ++t)
d[i][t][0] = max(d[i][t][0], d[i - 1][j][t]);
if(s[l][c] != 'R') continue ;
if(s[l + 1][c] == 'G' && s[l + 2][c] == 'W'){
for(int t = 0; t < 2 ; ++t)
d[i][t][1] = max(d[i][t][1], d[i][t][0] + 1);
}
if(s[l][c + 1] == 'G' && s[l][c + 2] == 'W'){
d[i][0][0] = max(d[i - 1][0][0] + 1, d[i][0][0]);
}
}
int Max = 0;
for(int i = 1; i <= L ; ++i)
for(int j = 0; j < 2 ; ++j)
for(int t = 0; t < 2 ; ++t)
Max = max(Max, d[i][j][t]);
ans = ans + Max;
}
printf("%d", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |