Submission #499763

#TimeUsernameProblemLanguageResultExecution timeMemory
499763KhizriCounting Mushrooms (IOI20_mushrooms)C++17
0 / 100
14 ms296 KiB
#include "mushrooms.h" #include <bits/stdc++.h> using namespace std; #define pb push_back bool ask(int l,int r){ vector<int>vt; for(int i=l;i<=r;i++){ vt.pb(i); } int x; if(vt.size()>1){ x=use_machine(vt); } else{ x=0; } if(x==0){ return true; } return false; } int count_mushrooms(int n) { int k=0; int x=0; int ans=0; while(k<n){ x=1-x; int l=k,r=n-1; int q=k; while(l<=r){ int m=(l+r)/2; if(ask(q,m)){ l=m+1; q=m; } else{ r=m-1; } } if(x){ ans+=(l-1-k+1); } k=l; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...