#include "routers.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
// static int l, n, q;
// static std::vector<int> p;
// static std::vector<int> answer;
// static int queries = 0;
// int use_detector(int x)
// {
// queries++;
// assert(x >= 0 && x <= l);
// std::vector<int>::iterator left, right;
// right = std::upper_bound(p.begin(), p.end(), x);
// left = std::prev(right);
// if (right == p.end()) {
// return n - 1;
// } else if ((x - *left) <= (*right - x)){
// return std::distance(p.begin(), left);
// } else {
// return std::distance(p.begin(), right);
// }
// }
std::vector<int> find_routers(int L, int N, int Q) {
ll last = 0;
vector<ll> ans = {0};
for(ll lable = 1; lable < N; lable++){
ll lo = last, hi = L;
while(lo < hi){
ll mid = (lo + hi) / 2;
ll x = use_detector(mid);
if(x >= lable) hi = mid;
else lo = mid+1;
}
ans.push_back(last + 2*(hi-last-1));
last += 2*(hi-last-1);
}
return ans;
}
// int main()
// {
// assert(scanf("%d %d %d", &l, &n, &q) == 3);
// p.resize(n);
// for (int i = 0; i < n; i++) {
// assert(scanf("%d", &p[i]) == 1);
// if (i) {
// assert(p[i-1] < p[i]);
// }
// }
// fclose(stdin);
// answer = find_routers(l, n, q);
// assert((int) answer.size() == n);
// for (int i = 0; i < n; i++)
// {
// assert(answer[i] >= 0 && answer[i] <= l && answer[i] % 2 == 0);
// }
// for (int i = 0; i < n; i++)
// {
// if (i) printf(" ");
// printf("%d", answer[i]);
// }
// printf("\n");
// printf("%d\n", queries);
// }
# | 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... |