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;
#define ll long long
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define pi pair<int, int>
#define all(x) (x).begin(),(x).end()
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
ll n;
cin >> n;
ll s=0,c=0,l=1,r=n-1;
for (int i=0; l<=r; i++) {
ll m=(r-l+1>2)?((l+r)/2):r;
if (i&1) {
c-=m;
}
else {
c+=m;
}
s=min(s,c);
l=m+1;
}
s=-s+1;
l=1,r=n-1;
ll ans=n;
if (n>1) {
cout << "? " << s << endl;
int a;
cin >> a;
}
for (int i = 0; l<=r; i++) {
ll m=(r-l+1>2)?((l+r)/2):r;
if (i&1) {
s-=m;
}
else {
s+=m;
}
cout << "? " << s << endl;
int resp;
cin >> resp;
if (resp) {
ans=m;
r=m-1;
}
else {
l=m+1;
}
}
cout << "= " << ans << endl;
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... |