#include "routers.h"
#include <bits/stdc++.h>
using namespace std;
vector<array<int, 2>> X;
void solve(int A, int B, int L, int R)
{
if (A == B)
{
X.push_back({L, R});
return;
}
int C = (A + B) / 2;
int l = L, r = R;
while (l < r)
{
int mid = (l + r + 1) >> 1;
if (use_detector(mid) > C) r = mid - 1;
else l = mid;
}
solve(A, C, L, l);
solve(C + 1, B, l + 1, R);
}
vector<int> find_routers(int L, int n, int q)
{
X.clear();
solve(0, n - 1, 0, L);
sort(X.begin(), X.end());
assert(X.size() == n);
vector<int> res = {0};
for (int i = 1; i < n; i++)
{
int d = X[i - 1][1] - res[i - 1];
res.push_back(res[i - 1] + d * 2);
}
return res;
}
# | 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... |