제출 #406444

#제출 시각아이디문제언어결과실행 시간메모리
406444LoboMiners (IOI07_miners)C++17
100 / 100
213 ms1092 KiB
#include <bits/stdc++.h> using namespace std; const long long INFll = 1e18; const int INFii = 1e9; const long long mod = (long long) 1e9 + 7; typedef long long ll; typedef int ii; typedef double dbl; #define endl '\n' #define sc second #define fr first #define mp make_pair #define pb push_back #define maxn 110000 //LEMBRAR DE MUDAR ii n, s[maxn]; string S; ii dp[2][4][4][4][4]; int main() { ios::sync_with_stdio(false); cin.tie(0); //freopen("in.in", "r", stdin); //freopen("__.out", "w", stdout); cin >> n; cin >> S; for(ii i = 0; i < n; i++) { if(S[i] == 'M') s[i] = 1; if(S[i] == 'F') s[i] = 2; if(S[i] == 'B') s[i] = 3; } for(ii i = n-1; i >= 0; i--) { for(ii a1 = 0; a1 < 4; a1++) for(ii a2 = 0; a2 < 4; a2++) for(ii b1 = 0; b1 < 4; b1++) for(ii b2 = 0; b2 < 4; b2++) { ii p1 = 3; if(a1 == 0 || a1 == a2 || a1 == s[i]) p1--; if(a2 == 0 || a2 == s[i]) p1--; ii p2 = 3; if(b1 == 0 || b1 == b2 || b1 == s[i]) p2--; if(b2 == 0 || b2 == s[i]) p2--; //cout << p1 << " " << p2 << endl; if(i != n-1) dp[i%2][a1][a2][b1][b2] = max(p1 + dp[(i+1)%2][s[i]][a1][b1][b2], p2 + dp[(i+1)%2][a1][a2][s[i]][b1]); else { dp[i%2][a1][a2][b1][b2] = max(p1,p2); //cout << p1 << " " << p2 << endl; } } } cout << dp[0][0][0][0][0]<< endl; }
#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...