Submission #1052188

#TimeUsernameProblemLanguageResultExecution timeMemory
1052188mychecksedadCounting Mushrooms (IOI20_mushrooms)C++17
80.71 / 100
5 ms856 KiB
#include "mushrooms.h" #include<bits/stdc++.h> using namespace std; #define pb push_back #define all(x) x.begin(),x.end() #define vi vector<int> #define pii pair<int,int> #define ff first #define ss second int count_mushrooms(int n) { vector<int> A, B; A.pb(0); int last = 1, add = 0; while(last < n){ if(A.size() > B.size()){ vector<int> q; int s = A.size(); for(int j = last; j < min(n, last + s); ++j){ q.pb(j); q.pb(A[j - last]); } last = min(n, last + s); int f = use_machine(q); s = q.size()/2 - 1; add += s - f/2; if(f%2==0) A.pb(q[0]); else B.pb(q[0]); }else{ vector<int> q; int s = B.size(); for(int j = last; j < min(n, last + s); ++j){ q.pb(j); q.pb(B[j - last]); } int f = use_machine(q); add += f/2; if(f%2==1) A.pb(q[0]); else B.pb(q[0]); last = min(n, last + s); } } return int(A.size()) + add; }
#Verdict Execution timeMemoryGrader output
Fetching results...