제출 #559556

#제출 시각아이디문제언어결과실행 시간메모리
559556ahmet34Finding Routers (IOI20_routers)C++14
0 / 100
2 ms1236 KiB
#include <bits/stdc++.h> #include "routers.h" using namespace std; using ll = long long; using pii = pair<int, int>; #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() const int INF = 2e9, N = 1e5+15, M = 998244353, LOG = 16; const ll LINF = 1e18; vector<int> bit; void upd(int i, int x) { for(; i < N; i+=(i & -i)) bit[i] = min(bit[i], x); } int mn(int i) { int ret = bit[0]; for( ; i > 0; i-=(i & -i)) ret = min(bit[i], ret); return ret; } vector<int> find_routers(int l, int n, int q) { vector<int> asked(l, -1); bit.assign(n+123, l-1); vector<int> ans {0}; auto Ask = [&] (int x) { return asked[x] = (asked[x] >= 0 ? asked[x] : use_detector(x)); }; for(int i = 1; i < n; i++) { int s = ans.back()+1, e = min(mn(n+5-i), l-1); //cout << i << ": "<< s << ", " << e << '\n'; while(s < e) { int m = (s + e + 1) / 2; int cur = Ask(m); if(cur > i-1) { e = m-1; upd(n+5-cur, m); //cout << n-cur << " updated with " << m << '\n'; } else s = m; } ans.push_back(ans.back() + 2 * (s - ans.back())); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...