# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
42175 | nonocut | Dango Maker (JOI18_dango_maker) | C++14 | 1126 ms | 181076 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;
#define pii pair<int,int>
#define X first
#define Y second
const int maxn = 3005;
int n,m;
char s[maxn][maxn];
int dp[maxn][3][3];
pii a[maxn*2][maxn];
int solve(int cur) {
int x,t0,t1;
for(x=n;x>=1;x--) {
for(t0=0;t0<=2;t0++) {
for(t1=0;t1<=2;t1++) {
dp[x][t0][t1] = dp[x+1][0][t0];
if(t0!=2 && t1!=2) {
dp[x][t0][t1] = max(dp[x][t0][t1], a[cur][x].X + dp[x+1][1][t0]);
}
dp[x][t0][t1] = max(dp[x][t0][t1], a[cur][x].Y + dp[x+1][2][t0]);
}
}
}
return dp[1][0][0];
}
int main() {
int i,j;
scanf("%d%d",&n,&m);
for(i=1;i<=n;i++) for(j=1;j<=m;j++) scanf(" %c",&s[i][j]);
for(i=1;i<=n;i++) {
for(j=1;j<=m;j++) {
int t0 = 0, t1 = 0;
if(s[i][j]=='R' && s[i][j+1]=='G' && s[i][j+2]=='W') {
t0 = 1;
}
if(s[i][j]=='R' && s[i+1][j]=='G' && s[i+2][j]=='W') {
t1 = 1;
}
a[i+j][i] = {t0,t1};
}
}
int ans = 0;
for(i=2;i<=n+m;i++) {
ans += solve(i);
}
printf("%d",ans);
}
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... |