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 "prize.h"
#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(239);
namespace {
int mx_cnt;
}
vector<vector<int>> mem;
vector<int> mask(int i) {
return mem[i] == vector<int>{-1, -1} ? mem[i] = ask(i) : mem[i];
}
int solve(int l, int r) {
if (l > r)
return -1;
if (l == r) {
auto a = mask(l);
if (a[0] + a[1] == 0)
return l;
return -1;
}
auto al = mask(l);
auto ar = mask(r);
if (al[0] + al[1] == 0)
return l;
if (ar[0] + ar[1] == 0)
return r;
if (al[0] + al[1] == ar[0] + ar[1] && al[0] == ar[0])
return -1;
int m = (l + r) / 2;
int res = solve(l, m);
if (res == -1)
res = solve(m + 1, r);
return res;
}
int find_best(int n) {
mem.resize(n, vector<int>{-1, -1});
return solve(0, n - 1);
}
Compilation message (stderr)
prize.cpp:10:5: warning: '{anonymous}::mx_cnt' defined but not used [-Wunused-variable]
10 | int mx_cnt;
| ^~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |