제출 #1116823

#제출 시각아이디문제언어결과실행 시간메모리
1116823vladiliusFinding Routers (IOI20_routers)C++17
96.56 / 100
5 ms848 KiB
#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; } mp[x] = use_detector(x); return mp[x]; }; vector<pii> rr(n); vector<bool> used(n); used[0] = 1; 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 = max(l1, 2 * m), rb = r1; while (lb + 1 < rb){ int mb = (lb + rb) / 2, t = f(mb); if (t > m){ rb = mb - 1; } else { lb = mb; } } while (f(rb) != m) rb--; rr[m].ss = rb; rr[m + 1].ff = rb + 1; solve(l, m - 1, l1, rr[m].ss); solve(m + 1, r, rr[m].ss, r1); }; solve(0, n - 2, 0, k); vector<int> out = {0}; for (int i = 0; i < n - 1; i++){ out.pb(2 * rr[i].ss - out.back()); }; return out; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...