Submission #416207

#TimeUsernameProblemLanguageResultExecution timeMemory
416207nicolaalexandraColors (BOI20_colors)C++14
0 / 100
1 ms200 KiB
#include <bits/stdc++.h> using namespace std; long long n,maxi,i; int query (int x){ int ans; cout<<"? "<<x<<endl; cin>>ans; return ans; } void answer (int x){ cout<<"= "<<x<<endl; } int main (){ //ifstream cin ("date.in"); //ofstream cout ("date.out"); cin>>n; for (maxi=0;;maxi++) if ((1LL<<maxi) > n) break; maxi--; long long sum = 0, sum2 = 0; for (i=maxi;i>=0;i-=2) sum += (1LL<<i); for (i=maxi-1;i>=0;i-=2) sum2 += (1LL<<i); long long x = n - sum, c = 0; query (x); for (i=maxi;i>=0;i--){ if ((maxi - i) % 2){ /// ma duc in stanga int ans = query (x - c - (1LL<<i)); x -= c + (1LL<<i); if (!ans) c += (1LL<<i); } else { /// ma duc in dreapta int ans = query (x + c + (1LL<<i)); x += c + (1LL<<i); if (!ans) c += (1L<<i); } } answer(c+1); 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...