제출 #95164

#제출 시각아이디문제언어결과실행 시간메모리
95164FedericoSMiners (IOI07_miners)C++14
100 / 100
160 ms73508 KiB
#include <iostream> using namespace std; typedef pair<int,int> pii; int N; char c; int DP[4][4][4][4][100005]; int T[100005]; int C(pii a, int b){ int A[]={0,0,0,0}; A[a.first]=1; A[a.second]=1; A[b]=1; return A[1]+A[2]+A[3]; } int F(pii a, pii b, int k){ if(k==N) return 0; if(!DP[a.first][a.second][b.first][b.second][k]) DP[a.first][a.second][b.first][b.second][k]= max( F({a.second,T[k]},b,k+1)+C(a,T[k]), F(a,{b.second,T[k]},k+1)+C(b,T[k]) ); return DP[a.first][a.second][b.first][b.second][k]; } int main(){ cin>>N; for(int i=0;i<N;i++){ cin>>c; if(c=='M') T[i]=1; else if(c=='F') T[i]=2; else T[i]=3; } cout<<F({0,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...