Submission #659984

#TimeUsernameProblemLanguageResultExecution timeMemory
659984jamezzzColors (BOI20_colors)C++17
0 / 100
1 ms324 KiB
#include <bits/stdc++.h> using namespace std; #define sf scanf #define pf printf #define pb push_back typedef long long ll; inline int ask(ll x){ pf("? %lld\n",x); fflush(stdout); int a;sf("%d",&a); return a; } inline void ans(ll x){ pf("= %lld\n",x); exit(0); } int main(){ ll n;sf("%lld",&n); ll lo=1,hi=n-1,mid,res=-1; vector<ll> v; while(lo<=hi){ mid=(lo+hi)>>1; v.pb(mid); lo=mid+1; } ll cur=1;int m=1; for(int i=v.size()-1;i>=0;--i){ cur+=m*v[i]; m=-m; } ask(cur); lo=1,hi=n-1; while(lo<=hi){ if(lo==hi&&res==-1){ res=lo; break; } mid=(lo+hi)>>1; cur+=m*mid; m=-m; if(ask(cur)==1)res=mid,hi=mid-1; else lo=mid+1; } ans(res); }

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:22:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  ll n;sf("%lld",&n);
      |         ^
Colors.cpp: In function 'int ask(ll)':
Colors.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  int a;sf("%d",&a);
      |          ^
#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...