This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using arr = array<int, 2>;
using arrr = array<int, 3>;
// mt19937 rng(1985022984);
ll last = -1;
set <ll> used = { -1 };
int query(int p)
{
used.insert(p);
cout << "? " << p << endl;
int a;
cin >> a;
last = p;
return a;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin >> n;
ll l = 1, r = n, mid;
ll a, b, c, d;
while (l != r)
{
mid = (l + r) >> 1;
a = -1, b = -1;
while (used.count(a) == 1 || used.count(b) == 1)
{
a = rand() % (n - mid);
b = a + mid;
}
c = query(a);
c++;
d = query(b);
if (d)
{
r = mid;
} else {
l = mid + 1;
}
}
cout << "= " << l << endl;
}
# | 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... |