제출 #956741

#제출 시각아이디문제언어결과실행 시간메모리
956741DeltaStructMiners (IOI07_miners)C++17
0 / 100
109 ms604 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n,id=numeric_limits<int>::lowest(); cin >> n; string s; cin >> s; vector dp(4,vector(4,vector(4,vector<int>(4,id)))); string u = "MFB"; dp[3][3][3][3] = 0; auto res = dp; for (char a:s){ int t = find(u.begin(),u.end(),a)-u.begin(); for (int i(0);i < 4;++i) for (int k(0);k < 4;++k) for (int j(0);j < 4;++j) for (int l(0);l < 4;++l){ if (dp[i][k][j][l]!=id){ res[k][t][j][l] = max(res[k][t][j][l],dp[i][k][j][l]+(i!=k)+(i!=t)+(k!=t)-(i!=3||k!=3)); res[i][k][l][t] = max(res[i][k][l][t],dp[i][k][j][l]+(j!=l)+(j!=t)+(l!=t)-(j!=3||l!=3)); } } swap(dp,res); } int r = 0; for (int i(0);i < 4;++i) for (int k(0);k < 4;++k) for (int j(0);j < 4;++j) for (int l(0);l < 4;++l){ r = max(r,dp[i][k][j][l]); } cout << r << 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...