제출 #145694

#제출 시각아이디문제언어결과실행 시간메모리
145694TadijaSebezDango Maker (JOI18_dango_maker)C++11
100 / 100
392 ms51612 KiB
#include <bits/stdc++.h> using namespace std; const int N=3005; const int M=2*N; const int inf=1e9+7; bool can[M][N][2]; char s[N][N]; int dp[N][2][2]; void Clear(){ for(int i=0;i<N;i++) dp[i][0][0]=dp[i][1][0]=dp[i][0][1]=dp[i][1][1]=-inf;} void ckmx(int &a, int b){ a=max(a,b);} int main() { int n,m; scanf("%i %i",&n,&m); for(int i=1;i<=n;i++) scanf("%s",s[i]+1); for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) { if(s[i][j]=='R' && s[i][j+1]=='G' && s[i][j+2]=='W') can[i+j][i][0]=1; if(s[i][j]=='R' && s[i+1][j]=='G' && s[i+2][j]=='W') can[i+j][i][1]=1; } int ans=0; for(int z=2;z<=n+m;z++) { Clear(); dp[0][0][0]=0; for(int i=1;i<=n;i++) { for(int x=0;x<2;x++) for(int y=0;y<2;y++) { ckmx(dp[i][0][x],dp[i-1][x][y]); if(can[z][i][0] && x==0 && y==0) ckmx(dp[i][0][x],dp[i-1][x][y]+1); if(can[z][i][1]) ckmx(dp[i][1][x],dp[i-1][x][y]+1); } } int tmp=0; for(int x=0;x<2;x++) for(int y=0;y<2;y++) ckmx(tmp,dp[n][x][y]); ans+=tmp; } printf("%i\n",ans); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

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