Submission #1057377

#TimeUsernameProblemLanguageResultExecution timeMemory
1057377c2zi6Counting Mushrooms (IOI20_mushrooms)C++14
80.71 / 100
6 ms728 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "mushrooms.h" int count_mushrooms(int n) { VI mek, zro; zro.pb(0); int ans = 1; int last = 1; while (last < n) { VI qr; for (int x : (mek.size() > zro.size() ? mek : zro)) { qr.pb(x); qr.pb(last++); if (last >= n) break; } int ret = use_machine(qr); int urish = (ret+1)/2; if (mek.size() > zro.size()) { ans += urish; if (ret & 1) zro.pb(last-1); else mek.pb(last-1); } else { ans += qr.size()/2 - urish; if (ret & 1) mek.pb(last-1); else zro.pb(last-1); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...