제출 #1151132

#제출 시각아이디문제언어결과실행 시간메모리
1151132emptypringlescanColors (BOI20_colors)C++20
100 / 100
1 ms408 KiB
#include <bits/stdc++.h> using namespace std; int32_t main(){ //ios::sync_with_stdio(0); //cin.tie(0); long long n; cin >> n; long long cur=1,smol=1,big=1; long long lo=1,hi=n,mid; while(lo<hi){ mid=(lo+hi)/2ll; if(cur>1) cur-=mid; else cur+=mid; lo=mid+1; smol=min(smol,cur); big=max(big,cur); } cur=2-smol; //cout << smol << ' ' << big << '\n'; lo=1,hi=n; cout << "? " << cur << endl; int x; cin >> x; long long dir=1; bool prev=true; while(lo<hi){ if(prev||lo==hi-1ll) mid=(lo+hi)/2ll; else mid=(lo+hi+1ll)/2ll; cur+=mid*dir; dir*=-1ll; cout << "? " << cur << endl; cin >> x; if(x) hi=mid,prev=false; else lo=mid+1ll,prev=true; } cout << "= " << lo << endl; }
#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...