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