이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "routers.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
vector<int> find_routers(int k, int n, int q){
map<int, int> mp;
auto f = [&](int x){
auto it = mp.find(x);
if (it != mp.end()){
return (*it).ss;
}
auto it1 = mp.lower_bound(x);
if (it1 != mp.end() && it1 != mp.begin() && (*it1).ss == (*prev(it1)).ss){
mp[x] = (*it1).ss;
}
else {
mp[x] = use_detector(x);
}
return mp[x];
};
vector<int> rr(n);
function<void(int, int, int, int)> solve = [&](int l, int r, int l1, int r1){
if (l > r) return;
int m = (l + r) / 2;
int lb = l1, rb = r1, L = 1e9;
while (lb + 1 < rb){
int mb = (lb + rb) / 2, t = f(mb);
if (t > m){
rb = mb - (t - m);
}
else if (t == m){
L = min(L, mb);
lb = mb;
}
else {
lb = mb + 2 * (m - t);
}
}
if (lb != rb) while (f(rb) != m) rb--;
rr[m] = rb;
L = min(L, rb);
solve(l, m - 1, l1, L - 1);
solve(m + 1, r, rr[m] + 1, r1);
};
solve(0, n - 2, 0, k);
vector<int> out = {0};
for (int i = 0; i < n - 1; i++){
out.pb(2 * rr[i] - out.back());
};
return out;
}
# | 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... |