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 main(){
int n;
cin >> n;
int res = 1;
int l = 1, r = 3;
while(r <= n){
cout << "? " << l << " " << r << "\n";
cout << flush;
int x;
cin >> x;
if(x == 1){
res = r-l+1;
if(l == 1) r += 2;
else{
l--;
r++;
}
}
else{
l++;
r++;
}
}
l = 1;
r = res+1;
while(r <= n){
cout << "? " << l << " " << r << "\n";
cout << flush;
int x;
cin >> x;
if(x == 1){
res = r-l+1;
if(l == 1) r += 2;
else{
l--;
r++;
}
}
else{
l++;
r++;
}
}
cout << "! " << res << "\n";
cout << flush;
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... |