제출 #644278

#제출 시각아이디문제언어결과실행 시간메모리
644278randomRandomMiners (IOI07_miners)C++14
100 / 100
357 ms1004 KiB
#include <iostream> using namespace std; const int MAXN = 1e5+7; int A[MAXN]; int DP[2][4][4][4][4]; int check(int a, int b, int c){ int result = 0; for(int i = 1; i <= 3; i++){ if(a == i || b == i || c == i){ result++; } } return result; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; string ciag; cin >> n; cin >> ciag; for(int i = 0; i < n; i++){ if(ciag[i] == 'M'){ A[i+1] = 1; }else if(ciag[i] == 'F'){ A[i+1] = 2; }else{ A[i+1] = 3; } } int obecny = 0; int drugi = 1; for(int i = n; i >= 0; i--){ for(int a = 0; a <= 3; a++){ for(int b = 0; b <= 3; b++){ for(int c = 0; c<=3; c++){ for(int d = 0; d <= 3; d++){ DP[obecny][a][b][c][d] = max(DP[drugi][b][A[i]][c][d] + check(a, b, A[i]), DP[drugi][a][b][d][A[i]] + check(c, d, A[i])); } } } } swap(obecny, drugi); } cout << DP[obecny][0][0][0][0]; 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...