Submission #213507

#TimeUsernameProblemLanguageResultExecution timeMemory
213507tatyamMiners (IOI07_miners)C++17
100 / 100
434 ms632 KiB
#include <bits/stdc++.h> using namespace std; const int INF = 0x3fffffff; #define all(a) begin(a), end(a) #define each(i,a) for(auto&& i : a) #define rep(n) for(int i = 0; i < (n); ++i) template<class T, class U> bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; } inline constexpr int kinds(int a, int b, int c){ if(a > b) swap(a, b); if(b > c) swap(b, c); if(a > b) swap(a, b); int ans = 3; if(!a || a == b) ans--; if(!b || b == c) ans--; return ans; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); string s; cin >> s >> s; each(i, s){ if(i == 'B') i = 1; else if(i == 'F') i = 2; else i = 3; } vector<int> dp1(1 << 8, -INF); dp1[0] = 0; each(c, s){ vector<int> dp2(1 << 8, -INF); rep(1 << 8){ int a1 = i >> 6 & 3, a2 = i >> 4 & 3, b1 = i >> 2 & 3, b2 = i & 3; int j = a2 << 6 | c << 4 | b1 << 2 | b2; chmax(dp2[j], dp1[i] + kinds(a1, a2, c)); j = a1 << 6 | a2 << 4 | b2 << 2 | c; chmax(dp2[j], dp1[i] + kinds(b1, b2, c)); } swap(dp1, dp2); } cout << *max_element(all(dp1)) << 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...