Submission #592253

#TimeUsernameProblemLanguageResultExecution timeMemory
592253hailColors (BOI20_colors)C++17
67 / 100
286 ms262144 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin>>n; int l=0; int u=n; vector<int> max_i(0); int k{}; while(k<n-1) { k=(k+n)/2; max_i.push_back(k); } k= -1; int c_prev{n}; for(auto i=max_i.rbegin(); i!=max_i.rend(); i++) { c_prev += k*(*i); k*=-1; } if(c_prev>n/2) c_prev = 1 + n-c_prev; cout<<"? "<<c_prev<<endl; cin>>k; int c_new; k=1; int inp; while(u-l>1) { c_new = c_prev+(k*((u+l)/2)); k*=-1; cout<<"? "<<c_new<<endl; cin>>inp; if(inp) u=abs(c_new-c_prev); else l=abs(c_new-c_prev); c_prev=c_new; } cout<<"= "<<u<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...