# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
433051 | ACmachine | 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 "routers.h"
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k, l) for(int i = (j); i < (k); i += (l))
#define FORD(i, j, k, l) for(int i = (j); i >= (k); i -= (l))
#define REP(i, n) FOR(i, 0, n, 1)
#define REPD(i, n) FORD(i, n, 0, 1)
#define pb push_back
typedef long long ll;
std::vector<int> find_routers(int l, int n, int q) {
vector<int> ans;
ans.pb(0);
vector<int> mapka(l, -1);
auto get = [&](int x){
if(mapka[x] != -1)
return mapka[x];
return mapka[x] = use_detector(x);
};
function<int(int, int, int)> dfs = [&](int l, int r, int v){
if(r - l <= 1)
return l;
int m = (l + r) >> 1;
if(get(m) <= v)
return dfs(m, r, v);
else
return dfs(l, m, v);
}
REP(i, n - 1){
int x = dfs(1, l, i);
ans.pb(x + (x - ans.back()));
}
return ans;
}