Submission #1031065

#TimeUsernameProblemLanguageResultExecution timeMemory
1031065ttamxColors (BOI20_colors)C++17
100 / 100
1 ms608 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; ll n; inline int ask(ll x){ cout << "? " << x << endl; int res; cin >> res; return res; } int main(){ cin.tie(nullptr)->sync_with_stdio(false); cin >> n; ll pos=1,dir=1,st=1,step=0; int cnt=0; for(ll i=n;i>1;i=(i+1)/2){ step+=i/2; pos+=dir*step; 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=n;i>1;){ st+=dir*(step+i/2); if(!ask(st)){ ans+=i/2; step+=i/2; i=(i+1)/2; }else{ i=i/2; } dir=-dir; } cout << "= " << ans << endl; }

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:20:9: warning: unused variable 'cnt' [-Wunused-variable]
   20 |     int cnt=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...