Submission #42173

#TimeUsernameProblemLanguageResultExecution timeMemory
42173nonocutDango Maker (JOI18_dango_maker)C++14
33 / 100
2045 ms112468 KiB
#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 f(int cur, int x, int t0, int t1) { if(x==n+1) return 0; if(dp[x][t0][t1]==-1) { dp[x][t0][t1] = f(cur,x+1,0,t0); if(t0!=2 && t1!=2) { dp[x][t0][t1] = max(dp[x][t0][t1], a[cur][x].X + f(cur,x+1,1,t0)); } dp[x][t0][t1] = max(dp[x][t0][t1], a[cur][x].Y + f(cur,x+1,2,t0)); } return dp[x][t0][t1]; } 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++) { memset(dp,-1,sizeof(dp)); // printf("i = %d : %d\n",i,f(i,1,0,0)); ans += f(i,1,0,0); } printf("%d",ans); }

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:24:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
                     ^
dango_maker.cpp:25:59: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1;i<=n;i++) for(j=1;j<=m;j++) scanf(" %c",&s[i][j]);
                                                           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...