# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1018759 | MarwenElarbi | Mađioničar (COI22_madionicar) | C++17 | 1335 ms | 596 KiB |
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 N;
int ask(int l, int r) {
printf("? %d %d\n", l + 1, r + 1);
fflush(stdout);
int ret;
scanf("%d", &ret);
return ret;
}
void ans(int L) {
printf("! %d\n", L);
fflush(stdout);
}
int main(void) {
scanf("%d", &N);
int r_odd = 0, r_even = 0;
for (int i = 0; i < N; ++i) {
while (i - r_odd - 1 >= 0 && i + r_odd + 1 < N && ask(i - r_odd - 1, i + r_odd + 1)) ++r_odd;
while (i - r_even >= 0 && i + r_even + 1 < N && ask(i - r_even, i + r_even + 1)) ++r_even;
}
ans(max(2 * r_odd + 1, 2 * r_even));
return 0;
}
Compilation message (stderr)
# | 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... |