Submission #798151

#TimeUsernameProblemLanguageResultExecution timeMemory
798151LiudasMiners (IOI07_miners)C++17
100 / 100
179 ms1000 KiB
#include <bits/stdc++.h> using namespace std; int dp[2][4][4][4][4]; int f(int a, int b, int c){ return (a == 1 || b == 1 || c == 1) + (a == 2 || b == 2 || c == 2) + (a == 3 || b == 3 || c == 3); } int main() { int N; cin >> N; string s; cin >> s; vector<int> v(N); for(int i = 0; i < N ; i++){ v[i] = (s.substr(i, 1) == "M" ? 1 : (s.substr(i, 1) == "F" ? 2 : 3)); } int x = 1, l = 0; for(int i = N-1; i >= 0; i --){ for(int a = 0; a < 4; a ++){ for(int b = 0; b < 4; b ++){ for(int c = 0; c < 4; c ++){ for(int d = 0; d < 4; d ++){ int e = v[i]; dp[x][a][b][c][d] = max(dp[l][b][e][c][d] + f(a,b,e), dp[l][a][b][d][e] + f(c,d,e)); } } } } x ^= 1; l ^= 1; } cout << dp[l][0][0][0][0] << endl; 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...