# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
180681 | gs13068 | Worm Worries (BOI18_worm) | C++17 | 3 ms | 380 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>
#include <map>
int __query(int x, int y, int z) {
printf("? %d %d %d\n", x, y, z);
fflush(stdout);
int ans = -1;
static int t;
(void)scanf("%d", &ans);
if (ans == -1) exit(0);
return ans;
}
std::map<int, int> M;
int query(int x, int y, int z) {
int t = x | y << 10 | z << 20;
if (M.find(t) == M.end()) M[t] = __query(x, y, z);
return M[t];
}
__attribute__((noreturn))
void guess(int x, int y, int z) {
printf("! %d %d %d\n", x, y, z);
exit(0);
}
const double p = 0.381966;
int main() {
int N, M, K, Q;
(void)scanf("%d %d %d %d", &N, &M, &K, &Q);
// TODO do something smart
if (M == 1) {
int L = 1, R = N;
int T = L * p + R * (1 - p) + .5;
while (L < R) {
if (T + T == L + R) T = L * (1 - p) + R * p + .236;
int T2 = L + R - T;
if (T > T2) {
int T3 = T;
T = T2;
T2 = T3;
}
if (query(T, 1, 1) > query(T2, 1, 1)) R = T2 - 1;
else {
L = T + 1;
T = T2;
}
}
guess(L, 1, 1);
}
}
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... |