# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
426569 | radaiosm7 | Finding Routers (IOI20_routers) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int i, lo, hi, mid;
vector<int> find_routers(int l, int n, int q) {
vector<int> ans(n);
ans[0] = 0;
for (i=1; i < n; ++i) {
lo = ans[i-1]+2;
hi = l;
while (lo < hi) {
mid = (lo+hi)/2;
if (use_detector(mid) == i) {
hi = mid;
}
else {
lo = mid+1;
}
}
ans[i] = 2*(mid-1)-ans[i-1];
}
return ans;
}