Submission #213502

#TimeUsernameProblemLanguageResultExecution timeMemory
213502tatyamMiners (IOI07_miners)C++17
100 / 100
124 ms680 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 overload3(_1, _2, _3, name, ...) name #define rep1(n) for(int i = 0; i < (n); ++i) #define rep2(i, n) for(int i = 0; i < (n); ++i) #define rep3(i, a, b) for(int i = (a); i < (b); ++i) #define rep(...) overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__) 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(){ 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) if(dp1[i] != -INF){ 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...