Submission #992683

#TimeUsernameProblemLanguageResultExecution timeMemory
992683ezzzayMiners (IOI07_miners)C++14
0 / 100
33 ms100692 KiB
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back const int N=1e5+5; int dp[4][4][4][4][N]; map<char,int>mp; signed main(){ mp['M']=1; mp['F']=2; mp['B']=3; int n; string s; cin>>n>>s; int h=mp[s[0]]; for(int i=0;i<n;i++){ for(int x1=0;x1<4;x1++){ for(int y1=0;y1<4;y1++){ for(int x2=0;x2<4;x2++){ for(int y2=0;y2<4;y2++){ dp[x1][y1][x2][y2][i]=-1e9; } } } } } return 0; dp[0][h][0][0][0]=1; dp[0][0][0][h][0]=1; for(int i=1;i<n;i++){ int k=mp[s[i]]; for(int x1=0;x1<4;x1++){ for(int y1=0;y1<4;y1++){ for(int x2=0;x2<4;x2++){ for(int y2=0;y2<4;y2++){ set<int>st; if(x1!=0)st.insert(x1); if(y1!=0)st.insert(y1); st.insert(k); int h=st.size(); dp[y1][k][x2][y2][i]=max(dp[y1][k][x2][y2][i],dp[x1][y1][x2][y2][i-1]+h); st.clear(); if(x2!=0)st.insert(x2); if(y2!=0)st.insert(y2); st.insert(k); h=st.size(); dp[x1][y1][y2][k][i]=max(dp[x1][y1][y2][k][i],dp[x1][y1][x2][y2][i-1]+h); } } } } } int mx=0; for(int i=0;i<4;i++){ for(int j=0;j<4;j++){ for(int k=0;k<4;k++){ for(int l=0;l<4;l++){ mx=max(mx,dp[i][j][k][l][n-1]); } } } } cout<<mx; }
#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...