Submission #1094187

#TimeUsernameProblemLanguageResultExecution timeMemory
1094187Marco_EscandonDango Maker (JOI18_dango_maker)C++11
13 / 100
1 ms460 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1000000007; #define x first #define y second int main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); ll n,m; cin>>n>>m; vector<vector<ll>> cad(n,vector<ll>(m,0)); for(int i=0; i<n; i++) { for(int j=0; j<m; j++) { char car; cin>>car; if(car=='R') cad[i][j]=1; else if(car=='G') cad[i][j]=2; else cad[i][j]=3; } } ll cont=0; for(int z=0; z<n; z++) { map<ll,ll> dp; ll a=z,b=0; ll i=0; while(a>=0&&b<m) { dp[i]=max(dp[i],dp[i-1]); if(a>=2) dp[i]=max(dp[i],dp[i-1]+((cad[a][b]==3)&(cad[a-1][b]==2)&(cad[a-2][b]==1))); if(b>=2) dp[i]=max(dp[i],dp[i-3]+((cad[a][b]==3)&(cad[a][b-1]==2)&(cad[a][b-2]==1))); a--; b++; i++; } cont+=dp[i-1]; } for(int z=1; z<m; z++) { map<ll,ll> dp; ll a=n-1,b=z; ll i=0; while(a>=0&&b<m) { dp[i]=max(dp[i],dp[i-1]); if(a>=2) dp[i]=max(dp[i],dp[i-1]+((cad[a][b]==3)&(cad[a-1][b]==2)&(cad[a-2][b]==1))); if(b>=2) dp[i]=max(dp[i],dp[i-3]+((cad[a][b]==3)&(cad[a][b-1]==2)&(cad[a][b-2]==1))); a--; b++; i++; } cont+=dp[i-1]; } cout<<cont; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...