This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map <ll,bool> bio;
int main()
{
int n;
cin >> n;
int mx = 62;
ll ans = 0LL;
cout << "? 1" << endl;
bio[1]=true;
ll lastask = 1;
for(int i = mx; i >= 0; i--)
{
ll now = ans + (1LL<<i);
if(lastask-now > 1 && !bio[lastask-now])
{
cout << "? " << lastask-now << endl;
int rez;
cin >> rez;
if(rez==1)
{
bio[lastask-now]=true;
lastask -= now;
continue;
}
else
{
bio[lastask-now]=true;
ans += (1LL<<i);
lastask -= now;
continue;
}
}
if(lastask+now <= n && !bio[lastask+now])
{
cout << "? " << lastask+now << endl;
int rez;
cin >> rez;
lastask += now;
bio[lastask]=true;
if(rez==0)
{
ans += (1LL<<i);
}
continue;
}
}
cout << "= " << ans+1;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |