# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
316089 | MrDomino | The Big Prize (IOI17_prize) | C++14 | 0 ms | 0 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>
#include "prize.h"
using namespace std;
mt19937 rng((long long) (new char));
int rn(int l, int r) {
return l + rng() % (r - l + 1);
}
int rep(int l, int r) {
if (l > r) {
return 0;
}
int m = (l + r) / 2;
vector<int> v = ask(m);
q++;
if (q > 100) {
while (1) {
}
}
if (v[0] == 0 && v[1] == 0) {
return m;
}
if (v[0] == 0) {
return rep(m + 1, r);
}
if (v[1] == 0) {
return rep(l, m - 1);
}
if (v[0] > v[1]) {
int x = rep(l, m - 1);
if (x) {
return x;
} else {
return rep(m + 1, r);
}
} else {
int x = rep(m + 1, r);
if (x) {
return x;
} else {
return rep(l, m - 1);
}
}
}
int find_best(int n) {
return rep(0, n - 1);
}