Submission #1057422

#TimeUsernameProblemLanguageResultExecution timeMemory
1057422c2zi6Counting Mushrooms (IOI20_mushrooms)C++14
80.43 / 100
7 ms852 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) { int max0 = n, max1 = n; VI qr; rep(i, n) qr.pb(i); int ret = use_machine(qr); int min0 = (ret+2)/2; int min1 = (ret+1)/2; setmin(max0, n - min1); setmin(max1, n - min0); 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...