# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1203483 | mayac | Finding Routers (IOI20_routers) | C++20 | 0 ms | 0 KiB |
#include <iostream>
#include <vector>
using namespace std;
std::vector<int> find_routers(int l, int n, int q) {
int idx = l,a,cur;
vector<int> ans(n,0);
for (int i = n-1; i >0; i--) {
cur = 0;
for (int step = idx/2; step > 0; step /= 2) {
cur += step;
a = use_detector(cur);
if (a >= i)cur -= step;
if (step > 1)step++;
}
idx = cur;
ans[i] = cur;
}
for (int i = 1; i < n; i++) {
ans[i] = ans[i] * 2 - ans[i - 1];
}
return ans;
}