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;
bool query(int x){
int p;
cout << "? " << 1 << '\n';
cout << flush;
cin >> p;
cout << "? " << x+1 << '\n';
cout << flush;
int t;
cin >> t;
if(t == 1) return true;
return false;
}
int main(){
int n;
cin >> n;
int l = 1, r = n;
while(l < r){
if(r == l+1){
if(query(l)){
r = l;
}
else{
l = r;
}
break;
}
int mid = (l+r)/2;
if(query(mid)){
r = mid;
}
else{
l = mid+1;
}
}
cout << "= " << l << '\n';
}
# | 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... |