# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
497705 | LittleCube | Worm Worries (BOI18_worm) | C++14 | 1 ms | 328 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 <stdio.h>
#include <stdlib.h>
int arr[1000005];
int query(int x, int y, int z)
{
if (arr[x] == 0)
{
printf("? %d %d %d\n", x, y, z);
fflush(stdout);
int ans = -1;
(void)scanf("%d", &ans);
if (ans == -1)
exit(0);
arr[x] = ans;
}
return arr[x];
}
__attribute__((noreturn)) void guess(int x, int y, int z)
{
printf("! %d %d %d\n", x, y, z);
exit(0);
}
int main()
{
int N, M, K, Q;
(void)scanf("%d %d %d %d", &N, &M, &K, &Q);
if (M == 1 && K == 1)
{
int L = 1, R = N;
while (L < R)
{
int mid = (L + R) / 2;
int lans = query(mid, 1, 1), rans = query(mid + 1, 1, 1);
if (lans <= rans)
L = mid + 1;
else
R = mid;
}
guess(L, 1, 1);
}
}
// 1 4 6 3 7 | 2 9 8 5 19 | 4 3
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... |