Submission #899550

#TimeUsernameProblemLanguageResultExecution timeMemory
899550NonozeMiners (IOI07_miners)C++17
100 / 100
358 ms756 KiB
#include <bits/stdc++.h> #define sz(x) (int)(x.size()) using namespace std; int n; string seq; vector<vector<vector<vector<int>>>> dp(4, vector<vector<vector<int>>> (4, vector<vector<int>> (4, vector<int>(4, 0)))); vector<vector<vector<vector<int>>>> lst=dp; int sum(int a, int b, int c) { int ans=0; for (int i=1; i<4; i++) { if (a==i || b==i || c==i) ans++; } return ans; } void solve() { cin >> n; cin >> seq; for (int i=n-1; i>=0; i--) { int vaut=1; if (seq[i]=='F') vaut=2; if (seq[i]=='B') vaut=3; for (int prec11=0; prec11<4; prec11++) { for (int prec12=0; prec12<4; prec12++) { for (int prec21=0; prec21<4; prec21++) { for (int prec22=0; prec22<4; prec22++) { dp[prec11][prec12][prec21][prec22]= max(sum(prec11, prec12, vaut)+lst[vaut][prec11][prec21][prec22], sum(prec21, prec22, vaut)+lst[prec11][prec12][vaut][prec21]); } } } } lst=dp; } cout << dp[0][0][0][0] << endl; return; } signed main() { ios::sync_with_stdio(0); cin.tie(0); int tt=1;// cin >> tt; while(tt--) solve(); 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...