# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
450410 | nonsensenonsense1 | Worm Worries (BOI18_worm) | C++17 | 1 ms | 220 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 <cstdio>
#include <algorithm>
int n, m, k, q;
int query(int x)
{
printf("? %d 1 1\n", x);
fflush(stdout);
scanf("%d", &x);
return x;
}
int main()
{
scanf("%d%d%d%d", &n, &m, &k, &q);
int l = 1, r = n, x = -1, xval, y = -1, yval;
while (l < r) {
if (x == -1) {
x = (34 * l + 21 * r) / 55;
if (y != -1) x = std::min(x, y - 1);
if (!x) {
++x;
++y;
yval = query(y);
}
xval = query(x);
}
if (y == -1) {
y = (21 * l + 34 * r - 1) / 55 + 1;
if (x != -1) y = std::max(y, x + 1);
if (y == n + 1) {
--x;
--y;
xval = query(x);
}
yval = query(y);
}
if (xval > yval) {
r = y - 1;
y = x;
yval = xval;
x = -1;
}
else {
l = x + 1;
x = y;
xval = yval;
y = -1;
}
}
printf("! %d 1 1\n", l);
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |