제출 #529691

#제출 시각아이디문제언어결과실행 시간메모리
529691jamezzz버섯 세기 (IOI20_mushrooms)C++17
80.71 / 100
11 ms460 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; #define pf printf #define pb push_back #define sz(x) (int)x.size() int count_mushrooms(int n){ vector<int> a,b,v; a.pb(0); for(int i=1;i<n;++i)v.pb(i); int na=1; while(!v.empty()){ vector<int> g; if(sz(a)>=sz(b)){ for(int i=0;i<sz(a);++i){ if(v.empty())break; g.pb(a[i]); g.pb(v.back()); v.pop_back(); } int res=use_machine(g); na+=sz(g)/2-(res+1)/2; if(res%2)b.pb(g.back()); else a.pb(g.back()); } else{ for(int i=0;i<sz(b);++i){ if(v.empty())break; g.pb(b[i]); g.pb(v.back()); v.pop_back(); } int res=use_machine(g); na+=(res+1)/2; if(res%2)a.pb(g.back()); else b.pb(g.back()); } } return na; }
#Verdict Execution timeMemoryGrader output
Fetching results...