Submission #1288021

#TimeUsernameProblemLanguageResultExecution timeMemory
1288021BlockOGMiners (IOI07_miners)C++20
100 / 100
163 ms652 KiB
#include <bits/stdc++.h> // mrrrow meeow :3 // go play vivid/stasis now! https://vividstasis.gay #define fo(i, a, b) for (auto i = (a); i < (b); i++) #define of(i, a, b) for (auto i = (b); i-- > (a);) #define f first #define s second #define pb push_back #define lb lower_bound #define ub upper_bound #define be(a) a.begin(), a.end() using namespace std; int ____init = [] { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); return 0; }(); int calc_add(int i) { int r[3] = {0, 0, 0}; r[i / 1 % 3] = 1; r[i / 3 % 3] = 1; r[i / 9 % 3] = 1; return r[0] + r[1] + r[2]; } int full(int a) { return a + a * 3 + a * 9; } int change(int i, int a) { return i % 27 / 3 + a * 9; } int main() { string s; cin >> s >> s; array<int, 27> oo, on; array<int, 729> o, n; oo.fill(INT_MIN), o.fill(INT_MIN); oo[full(s[0] == 'M' ? 0 : s[0] == 'F' ? 1 : 2)] = 1; fo(i, 1, s.size()) { int a = s[i] == 'M' ? 0 : s[i] == 'F' ? 1 : 2; on.fill(INT_MIN), n.fill(INT_MIN); fo(j, 0, 27) { on[change(j, a)] = max(on[change(j, a)], oo[j] + calc_add(change(j, a))); n[j + full(a) * 27] = max(n[j + full(a) * 27], oo[j] + 1); n[full(a) + j * 27] = max(n[full(a) + j * 27], oo[j] + 1); fo(k, 0, 27) { n[change(j, a) + k * 27] = max(n[change(j, a) + k * 27], o[j + k * 27] + calc_add(change(j, a))); n[k + change(j, a) * 27] = max(n[k + change(j, a) * 27], o[k + j * 27] + calc_add(change(j, a))); } } swap(oo, on), swap(o, n); } int res = 0; for (int i : oo) res = max(res, i); for (int i : o) res = max(res, i); cout << res; }
#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...