이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "routers.h"
#include <bits/stdc++.h>
using namespace std;
int solve(int low, int upp, int val) {
while (low < upp) {
int mid = (low + upp + 1) / 2;
int qres = use_detector(mid);
// cerr << mid << endl;
if (qres >= val) upp = mid - 1;
else low = mid;
}
return low;
}
vector<int> find_routers(int l, int n, int q) {
vector<int> ans;
ans.push_back(0);
if (n == 2) {
int res = solve(0, l, 1);
ans.push_back(res * 2);
return ans;
}
vector<pair<int, int>> close;
close.push_back({0, 0});
constexpr int jump = 62;
for (int i = jump; i < l; i += jump) close.push_back({use_detector(i), i});
close.push_back({use_detector(l), l});
for (int i = 1; i < n; ++i) {
auto upp = lower_bound(close.begin(), close.end(), make_pair(i, 0));
auto low = prev(upp);
int res = solve(low->second, upp->second, i);
ans.push_back(2 * res - ans.back());
}
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... |