Submission #800702

#TimeUsernameProblemLanguageResultExecution timeMemory
800702FEDIKUSCounting Mushrooms (IOI20_mushrooms)C++17
0 / 100
1 ms208 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; const int maxn=20010; int count_mushrooms(int n) { vector<int> aovi={0}; vector<int> bovi; int ret=1; int w=100; for(int i=1;i<n;i++){ if(max(aovi.size(),bovi.size())<2){ int sta=use_machine({0,i}); if(sta==1) bovi.push_back(i); else aovi.push_back(i); ret=aovi.size(); continue; } bool zamenio=false; if(bovi.size()>=aovi.size()) zamenio=true; int uzimam=int(aovi.size())>=w ? int(aovi.size()):2; vector<int> tmp; for(int j=i;j<min(i+int(aovi.size()),n);j++){ tmp.push_back(aovi[j-i]); tmp.push_back(j); } int klkb=use_machine(tmp); i+=uzimam-1; int bio=klkb; if(klkb&1) bovi.push_back(tmp.back()); else aovi.push_back(tmp.back()); klkb=klkb/2+(klkb&1); int klka=tmp.size()/2-klkb; ret+=(zamenio ? klkb:klka); if(bio&1) klkb--; if(klkb==int(tmp.size())/2-1) for(int j=1;j<int(tmp.size())-1;j+=2) bovi.push_back(tmp[j]); else if(klkb==0) for(int j=1;j<int(tmp.size())-1;j+=2) aovi.push_back(tmp[j]); if(zamenio) swap(aovi,bovi); } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...