제출 #862499

#제출 시각아이디문제언어결과실행 시간메모리
862499JakobZorzMiners (IOI07_miners)C++14
9 / 100
125 ms98900 KiB
#include<iostream> #include<vector> #include<queue> #include<stack> #include<algorithm> #include<limits.h> #include<math.h> #include<map> #include<set> #include<unordered_map> #include<unordered_set> #include<iomanip> typedef long long ll; typedef long double ld; using namespace std; const int MOD=1e9+7; //typedef pair<ll,ll>Point; //typedef pair<ll,ll>Line; //#define x first //#define y second int n; string str; int get_val(int a,int b,int c){ int res=1; if(a==b||b==c||a==c) res=2; if(a==b&&b==c) res=3; return res; } bool dpt[4][4][4][4][100000]; int dp[4][4][4][4][100000]; int get(int m1,int m2,int m3,int m4,int i){ if(i==n) return 0; if(dpt[m1][m2][m3][m4][i]) return dp[m1][m2][m3][m4][i]; int curr=0; if(str[i]=='M') curr=1; if(str[i]=='B') curr=2; if(str[i]=='F') curr=3; int r1=get(m2,curr,m3,m4,i+1)+get_val(m1,m2,curr); int r2=get(m1,m2,m4,curr,i+1)+get_val(m1,m2,curr); dpt[m1][m2][m3][m4][i]=true; dp[m1][m2][m3][m4][i]=max(r1,r2); return max(r1,r2); } int main(){ ios::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); cin>>n; cin>>str; cout<<get(0,0,0,0,0)<<"\n"; return 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...