# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
723557 | MDSPro | Worm Worries (BOI18_worm) | C++17 | 3 ms | 4176 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 <vector>
#include <random>
#include <ctime>
#include <iostream>
std::mt19937 rnd(22);
std::vector<int> kn;
int qq = 0;
int query(int x, int y = 1, int z = 1) {
if(kn[x] != 0) return kn[x];
printf("? %d %d %d\n", x, y, z);
fflush(stdout);
int ans; // ans = rand(); qq++;
(void)scanf("%d", &ans);
if (ans == -1) exit(0);
return kn[x] = ans;
}
__attribute__((noreturn))
void guess(int x, int y = 1, int z = 1) {
printf("! %d %d %d\n", x, y, z);
// std::cerr << qq << '\n';
exit(0);
}
int main() {
int N, M, K, Q;
(void)scanf("%d %d %d %d", &N, &M, &K, &Q);
kn.resize(N+1);
int l = 1, r = N;
while(r-l > 2){
int m1 = (r+l+l)/3,m2 = (r+r+l)/3;
if(query(l) > query(r)){
if(query(m2) <= query(l)) {
r = m2;
continue;
}
} else {
if(query(m1) <= query(r)) {
l = m1;
continue;
}
}
if(query(m1) < query(m2)) l = m1;
else r = m2;
}
int mx = l;
for(int i = l+1; i <= r; ++i) if(query(i) > query(mx)) mx = i;
guess(mx);
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... |