Submission #432536

#TimeUsernameProblemLanguageResultExecution timeMemory
432536TryMax버섯 세기 (IOI20_mushrooms)C++17
54.46 / 100
15 ms308 KiB
#include "mushrooms.h" #include <bits/stdc++.h> #ifdef LOCAL #include "stub.cpp" #endif // LOCAL #define f first #define s second #define pb push_back using namespace std; const int N = 2e5 + 10, C = 150; int a[N]; int count_mushrooms(int n){ int ans = 1; for(int i = 1; i < C; ++i){ if(i >= n) break; vector<int> x; x.pb(i - 1); x.pb(i); a[i] = a[i - 1] ^ use_machine(x); ans += (a[i] == 0); } // cout << ans << endl; for(int i = 1; i <= (n + C - 1) / C; ++i){ vector<int> x; for(int j = 0; j < min(n, C); ++j) if(a[j] == 0){ if(i * C + j >= n) break; x.pb(j), x.pb(i * C + j); } if(!x.empty()){ int cntb = (use_machine(x) + 1) / 2; ans += x.size() / 2 - cntb; } x.clear(); for(int j = 0; j < min(n, C); ++j) if(a[j] == 1){ if(i * C + j >= n) break; x.pb(j), x.pb(i * C + j); } if(!x.empty()){ int cnta = (use_machine(x) + 1) / 2; ans += cnta; } } return ans; } /* 3 0 1 1 1 2 4 0 1 0 0 3 2 */
#Verdict Execution timeMemoryGrader output
Fetching results...