이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |