#include "routers.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> find_routers(int l, int n, int q) {
vector<int> ans(n);
ans[0] = 0;
int road[l];
memset(road, -1, sizeof(road));
for(int i = 1; i < n; i++){
int lft = ans[i - 1] + 1;
int r = l - (n - i - 1);
int pos = -1;
while(lft <= r){
int m = (lft + r) / 2;
if(road[m] == -1) road[m] = use_detector(m);
if(road[m] >= i){
r = m - 1;
pos = m;
}
else lft = m + 1;
}
int tmp = pos - ans[i - 1];
ans[i] = pos + (tmp - 1) - 1;
}
return ans;
}
# | 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... |