Submission #948225

#TimeUsernameProblemLanguageResultExecution timeMemory
948225ezzzayDango Maker (JOI18_dango_maker)C++14
13 / 100
2 ms4564 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define double long double const int N=3e3+6; char arr[N][N]; int ans=0; int n,m; int dp[N][N]; void fun(int y, int x, int w){ if(dp[y][x]>w+1)return; dp[y][x]=w; ans=max(ans,w); for(int i=y;i<=n;i++){ if(i==y){ for(int j=x;j<=m;j++){ if(arr[i][j]=='R' and arr[i][j+1]=='G' and arr[i][j+2]=='W' and dp[i][j]<=w){ arr[i][j]='X'; arr[i][j+1]='X'; arr[i][j+2]='X'; fun(i,j,w+1); arr[i][j]='R'; arr[i][j+1]='G'; arr[i][j+2]='W'; } if(arr[i][j]=='R' and arr[i+1][j]=='G' and arr[i+2][j]=='W' and dp[i][j]<=w){ arr[i][j]='X'; arr[i+1][j]='X'; arr[i+2][j]='X'; fun(i,j,w+1); arr[i][j]='R'; arr[i+1][j]='G'; arr[i+2][j]='W'; } } } else{ for(int j=1;j<=m;j++){ if(arr[i][j]=='R' and arr[i][j+1]=='G' and arr[i][j+2]=='W' and dp[i][j]<=w ){ arr[i][j]='X'; arr[i][j+1]='X'; arr[i][j+2]='X'; fun(i,j,w+1); arr[i][j]='R'; arr[i][j+1]='G'; arr[i][j+2]='W'; } if(arr[i][j]=='R' and arr[i+1][j]=='G' and arr[i+2][j]=='W' and dp[i][j]<=w ){ arr[i][j]='X'; arr[i+1][j]='X'; arr[i+2][j]='X'; fun(i,j,w+1); arr[i][j]='R'; arr[i+1][j]='G'; arr[i+2][j]='W'; } } } } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>m; int cnt=0; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ dp[i][j]=0; cin>>arr[i][j]; } } fun(1,1,0); cout<<ans; }

Compilation message (stderr)

dango_maker.cpp: In function 'int main()':
dango_maker.cpp:70:9: warning: unused variable 'cnt' [-Wunused-variable]
   70 |     int cnt=0;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...