이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
int query(int l, int r) {
cout << "? " << l << " " << r << endl;
int x;
cin >> x;
return x;
}
int get1(int p, int d, int n) {
if(p - d < 1 || p + d > n) return 0;
return query(p - d, p + d);
}
int get2(int p, int d, int n) {
if(p - d + 1 < 1 || p + d > n) return 0;
return query(p - d + 1, p + d);
}
int main() {
int n, ans1=0, ans2=0;
cin >> n;
for(int i=1; i<=n; i++) while(get1(i, ans1+1, n)) ans1++;
for(int i=1; i+1<=n; i++) while(get2(i, ans2+1, n)) ans2++;
cout << "! " << max(2 * ans1 + 1, 2 * ans2) << 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... |