제출 #636316

#제출 시각아이디문제언어결과실행 시간메모리
636316gromperenMiners (IOI07_miners)C++14
84 / 100
1581 ms596 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int MAXN = 1e5+5; int dp[2][4][4][4][4]; const int INF = 1e9+7; int main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; string s; cin >> s; map<char,int> mp; mp['M']=1; mp['F']=2; mp['B']=3; memset(dp, -INF, sizeof(dp)); dp[1][0][0][0][0] = 0; int ans = 0; for (int i = 0; i <n; ++i) { int ic = i%2; int p = mp[s[i]]; //cerr << p << " "; for (int j = 0; j <= 3; ++j) {for (int k = 0; k <= 3; ++k) { for (int l = 0; l <= 3; ++l) {for (int m = 0; m <= 3; ++m) { set<int> st; st.insert(p); st.insert(j); st.insert(k); st.erase(0); int inc = st.size(); //if (p == 0 || j == 0 || k == 0) inc--; dp[ic][p][j][l][m] = max(dp[ic][p][j][l][m], inc+dp[ic^1][j][k][l][m]); dp[ic][l][m][p][j] = max(dp[ic][l][m][p][j], inc+dp[ic^1][l][m][j][k]); } } } } } for (int j = 0; j <= 3; ++j) {for (int k = 0; k <= 3; ++k) { for (int l = 0; l <= 3; ++l) {for (int m = 0; m <= 3; ++m) { ans = max(ans, dp[0][j][k][l][m]); ans = max(ans, dp[1][j][k][l][m]); }}}} cout << ans << "\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...