Submission #100334

#TimeUsernameProblemLanguageResultExecution timeMemory
100334tinjyuMiners (IOI07_miners)C++14
100 / 100
402 ms840 KiB
#include <iostream> using namespace std; int n,dp[2][4][4][4][4],a[100005]; int find(int x,int y,int z) { int t=0; for(int i=1;i<=3;i++)if(x==i || y==i || z==i)t++; return t; } int main(){ cin>>n; for(int i=1;i<=n;i++) { char c; cin>>c; if(c=='M')a[i]=1; if(c=='F')a[i]=2; if(c=='B')a[i]=3; } int d=1,e=0; for(int i=n;i>=0;i--) { swap(d,e); for(int j=0;j<=3;j++) { for(int k=0;k<=3;k++) { for(int l=0;l<=3;l++) { for(int m=0;m<=3;m++) { dp[d][j][k][l][m]=max(dp[e][k][a[i]][l][m]+find(j,k,a[i]),dp[e][j][k][m][a[i]]+find(l,m,a[i])); } } } } } cout<<dp[d][0][0][0][0]; }
#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...