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(){
ios::sync_with_stdio(false);
int n;
cin >> n;
int sz=2;
for (int i=1;i<=n;i++){
int x=1;
while (x){
int l=i-sz/2+1,r=i+sz/2;
if (l > 0 && r <= n){
cout << "? " << l << " " << r << endl;
cin >> x;
if (x) sz+=2;
}
else x=0;
}
}
int sz2=3;
for (int i=1;i<=n;i++){
int x=1;
while (x){
int l=i-sz2/2,r=i+sz2/2;
if (l > 0 && r <= n){
cout << "? " << l << " " << r << endl;
cin >> x;
if (x) sz2+=2;
}
else x=0;
}
}
cout << max(sz,sz2)-2 << "\n";
return 0;
}
//0 1 1 2 2 3 1
//2 4 1 2 2 5 1
# | 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... |