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;
int Debug = 1;
long long N;
long long C = 10;
long long prevs = 0;
int getans(long long pos) {
cout << "? " << pos << endl;
if (Debug == 1) {
int x;
cin >> x;
return x;
}
if (Debug == 2) {
int x = -1;
if (abs(prevs - pos) < C) x = 0;
else x = 1;
prevs = pos;
return x;
}
return -1;
}
int main() {
// Step #1. Input
cin >> N;
// Step #2. Get Answer
int cl = 1, cr = N, cm, minx = N;
for (int i = 0; i < 32; i++) {
cm = (cl + cr) / 2;
getans(1);
int z = getans(1 + cm);
if (z == 1) { minx = min(minx, cm); cr = cm; }
else { cl = cm; }
}
cout << "= " << minx << 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... |