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>
#define ll long long
#define fastIO cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);
#define mid ((l + r) / 2)
#define lChild ((index * 2) + 1)
#define rChild ((index * 2) + 2)
using namespace std;
void solve(ll _) {
ll n; cin>>n;
if(n == 1) {
cout<<"= 1"<<endl;
return;
}
cout<<"? "<<1<<endl;
bool curr; cin>>curr;
ll ans = n;
ll last = 1, now = n;
bool left = true;
while(true) {
cout<<"? "<<now<<endl;
cin>>curr;
if(curr == 1) ans = abs(now - last);
ll temp = last;
last = now;
now = temp + (left ? 1 : -1);
if(now == last) break;
left = !left;
}
cout<<"= "<<ans<<endl;
}
int main() {
fastIO
//freopen("file.in", "r", stdin);
//freopen("file.out", "w", stdout);
ll t = 0; solve(t);
}
# | 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... |