제출 #106190

#제출 시각아이디문제언어결과실행 시간메모리
106190mohammedehab2002Dango Maker (JOI18_dango_maker)C++11
100 / 100
1202 ms24548 KiB
#include <iostream> #include <string.h> using namespace std; int dp[5005][3][3],n,m; char arr[5005][5005]; int solve(int i,int x,int y,int a,int b) { if (!x || y>m) return 0; if (dp[i][a][b]!=-1) return dp[i][a][b]; int ans=solve(i+1,x-1,y+1,0,a); if (arr[x][y]=='R') { if (arr[x][y+1]=='G' && arr[x][y+2]=='W') ans=max(ans,solve(i+1,x-1,y+1,1,a)+1); if (arr[x+1][y]=='G' && arr[x+2][y]=='W' && a!=1 && b!=1) ans=max(ans,solve(i+1,x-1,y+1,2,a)+1); } return dp[i][a][b]=ans; } int main() { int ans=0; scanf("%d%d",&n,&m); for (int i=1;i<=n;i++) { for (int j=1;j<=m;j++) scanf(" %c",&arr[i][j]); } for (int i=1;i<n+m;i++) { memset(dp,-1,sizeof(dp)); ans+=solve(0,min(i,n),max(1,i-n+1),0,0); } printf("%d",ans); }

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

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:25:7: 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:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c",&arr[i][j]);
   ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...