제출 #917708

#제출 시각아이디문제언어결과실행 시간메모리
917708NinedesuDango Maker (JOI18_dango_maker)C++14
100 / 100
120 ms150440 KiB
#include<bits/stdc++.h> #define pii pair<pair<int,int>,pair<int,int>> using namespace std; const int N=3002; int n,m; int ans; int dp[N][N][3]; bool vis[N][N][3]; string s[N]; int main(){ ios_base::sync_with_stdio(0),cin.tie(0); cin >> n >> m; for(int i=1; i<=n; i++){ cin >> s[i]; s[i]="x"+s[i]; } for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ if(s[i][j]=='G'){ int tmp1=0,tmp2=0; if(j>1&&s[i][j-1]=='R'&&j<m&&s[i][j+1]=='W'){ if(!vis[i-1][j+1][1])dp[i][j][1]=dp[i-1][j+1][0]+dp[i-1][j+1][1]+1; else dp[i][j][1]=max(dp[i-1][j+1][0],dp[i-1][j+1][1]+1); vis[i][j][1]=true; } if(i>1&&s[i-1][j]=='R'&&i<n&&s[i+1][j]=='W'){ if(!vis[i-1][j+1][2])dp[i][j][2]=dp[i-1][j+1][0]+dp[i-1][j+1][2]+1; else dp[i][j][2]=max(dp[i-1][j+1][0],dp[i-1][j+1][2]+1); vis[i][j][2]=true; } } dp[i][j][0]=max(dp[i-1][j+1][0],max(dp[i-1][j+1][2],dp[i-1][j+1][1])); } dp[i][0][0]=max(dp[i-1][1][0],max(dp[i-1][1][2],dp[i-1][1][1])); for(int j=0; j<=m; j++){ dp[n+1][j][0]=max(dp[n][j+1][0],max(dp[n][j+1][2],dp[n][j+1][1])); } } for(int i=1; i<=n+1; i++)ans+=dp[i][0][0]; for(int j=1; j<=m; j++)ans+=dp[n+1][j][0]; cout << ans; return 0; }

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

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:22:21: warning: unused variable 'tmp1' [-Wunused-variable]
   22 |                 int tmp1=0,tmp2=0;
      |                     ^~~~
dango_maker.cpp:22:28: warning: unused variable 'tmp2' [-Wunused-variable]
   22 |                 int tmp1=0,tmp2=0;
      |                            ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...