Submission #1008055

#TimeUsernameProblemLanguageResultExecution timeMemory
1008055vjudge1Miners (IOI07_miners)C++17
100 / 100
145 ms748 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define endl '\n' #define FF first #define SS second #define all(a) a.begin(), a.end() #define mod (ll)(1000000007) int count(int a, int b, int c) { if (a == b && b == c) { return 1; } if (a == b || b == c || a == c) { return 2; } return 3; } signed main() { ios_base::sync_with_stdio(0);cin.tie(0); int n; string s; cin >> n >> s; vector<vector<vector<vector<int>>>> dp(3, vector<vector<vector<int>>>(3, vector<vector<int>>(3, vector<int>(3)))); for (int i = 0; i < n; i++) { vector<vector<vector<vector<int>>>> Nxt = dp; int l = 0; if (s[i] == 'F') { l = 1; } else if (s[i] == 'B') { l = 2; } for (int a = 0; a < 3; a++) { for (int b = 0; b < 3; b++) { for (int c = 0; c < 3; c++) { for (int d = 0; d < 3; d++) { Nxt[b][l][c][d] = max(Nxt[b][l][c][d], dp[a][b][c][d] + count(a, b, l)); Nxt[a][b][d][l] = max(Nxt[a][b][d][l], dp[a][b][c][d] + count(c, d, l)); } } } } dp = Nxt; } int ans = 0; for (int a = 0; a < 3; a++) { for (int b = 0; b < 3; b++) { for (int c = 0; c < 3; c++) { for (int d = 0; d < 3; d++) { ans = max(ans, dp[a][b][c][d]); } } } } cout << ans - 6; }
#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...