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>
using namespace std;
int use_detector(int x);
unordered_map < int, int > ans;
int query(int x) {
if (ans.find(x) != ans.end()) return ans[x];
return ans[x] = use_detector(x);
}
int detector(int l, int r, int router) {
int low = r, hi = l;
while (low < hi) {
int m = (low + hi) / 2;
if (query(m) >= router) hi = m;
else low = m + 1;
}
return low;
}
vector < int > find_routers(int l, int n, int q) {
vector < int > p(n);
p[0] = 0;
for (int i = 1; i < n; ++i) {
p[i] = 2 * (detector(l, p[i - 1], i) - 1) - p[i - 1];
}
return p;
}
# | 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... |