# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1230203 | lioow | Finding Routers (IOI20_routers) | C++20 | 0 ms | 0 KiB |
#include "routers.h"
#include <vector>
#include <cassert>
#include <cstdio>
#include <algorithm>
using namespace std;
std::vector<int> find_routers(int le, int n, int q) {
vector<int>ans(n);
ans[0]=0;
vector<int>lol(n);
for(int i=0;i<=n-1;i++){
int l=(i==0?0:ans[i-1]+1);
int r=le;
int an=-1;
int lol=-1;
while(l<=r){
int mid=(l+r)/2;
int nw=use_detector(mid);
if(nw>i) r=mid-1;
else {
an=mid;
l=mid+1;
}
}
lol[i]=an;
if(i>0) ans[i]=(lol[i]+lol[i-1])/2;
}
return ans;
}