# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1251899 | kolpo0210 | Finding Routers (IOI20_routers) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
int use_detector(int);
int[] find_routers(int l, int n, int q) {
vector<int> pos(n);
pos[0] = 0;
for (int i = 1; i < n; ++i) {
int lo = pos[i-1] + 2, hi = l, mid, res = l;
while (lo <= hi) {
mid = ((lo + hi) / 2) / 2 * 2;
int label = use_detector(mid);
if (label >= i + 1) {
res = mid;
hi = mid - 2;
} else {
lo = mid + 2;
}
}
pos[i] = 2 * res - pos[i - 1];
}
return pos;
}