제출 #1030699

#제출 시각아이디문제언어결과실행 시간메모리
1030699ttamxColors (BOI20_colors)C++17
0 / 100
1 ms344 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int LG=59; inline int ask(int x){ cout << "? " << x << endl; int res; cin >> res; return res; } int main(){ cin.tie(nullptr)->sync_with_stdio(false); ll n; cin >> n; ll pos=1,dir=1,st=1,step=0; for(ll i=1LL<<LG;i>0;i>>=1){ if(step+i>n-1)continue; step+=i; pos+=dir*step; if(pos>n){ ll dif=pos-n; pos-=dif,st-=dif; } if(pos<1){ ll dif=1-pos; pos+=dif,st+=dif; } dir=-dir; } ll ans=1; ask(st); dir=1,step=0; for(ll i=1LL<<LG;i>0;i>>=1){ if(step+i>n-1)continue; st+=dir*i; if(!ask(st)){ ans+=i; step+=i; } dir=-dir; } cout << "= " << ans << 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...