Submission #42175

#TimeUsernameProblemLanguageResultExecution timeMemory
42175nonocutDango Maker (JOI18_dango_maker)C++14
100 / 100
1126 ms181076 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 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)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:28: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:29: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...