Submission #69001

#TimeUsernameProblemLanguageResultExecution timeMemory
69001TuGSGeReLMiners (IOI07_miners)C++14
100 / 100
96 ms32528 KiB
#include<bits/stdc++.h> #define ll long long #define mp make_pair #define pub push_back #define pob pop_back #define ss second #define ff first #define ext exit(0) using namespace std; int n,i,j,p,t,k,a,dp[100001][3][3][3][3],ans; string s; inline int sol(int o, int oo , int ooo){ if(o==oo && oo==ooo) return 1; else if(o==oo || o==ooo || ooo==oo) return 2; else return 3; } int main (){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n>>s; for(i=0;i<n;i++){ if(s[i]=='M') a=0; else if(s[i]=='B') a=1; else a=2; for(j=0;j<3;j++){ for(k=0;k<3;k++){ for(t=0;t<3;t++){ for(p=0;p<3;p++){ dp[i+1][k][a][t][p]=max(dp[i+1][k][a][t][p],dp[i][j][k][t][p]+sol(k,a,j)); dp[i+1][j][k][p][a]=max(dp[i+1][j][k][p][a],dp[i][j][k][t][p]+sol(t,a,p)); } } } } } for(j=0;j<3;j++){ for(k=0;k<3;k++){ for(t=0;t<3;t++){ for(p=0;p<3;p++) ans=max(ans,dp[n][j][k][t][p]-6); } } } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...