제출 #1109119

#제출 시각아이디문제언어결과실행 시간메모리
1109119Neco_arcTwo Currencies (JOI23_currencies)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #ifndef ONLINE_JUDGE #include <bits/debug.hpp> #endif // ONLINE_JUDGE #define ll long long #define ull unsigned long long #define all(x) x.begin(), x.end() #define Neco "hai loai tien te" #define resp(x) sort(all(x)), x.resize(unique(all(x)) - x.begin()) #define getbit(x,i) ((x >> i)&1) #define _left id * 2, l, mid #define _right id * 2 + 1, mid + 1, r #define cntbit(x) __builtin_popcountll(x) #define fi(i, a, b) for(int i = a; i <= b; i++) #define fid(i, a, b) for(int i = a; i >= b; i--) #define maxn (int) 1e5 + 7 using namespace std; const ll mod = 1e9 + 7; //972663749 const ll base = 911382323; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll GetRandom(ll l, ll r) { return uniform_int_distribution<ll> (l, r)(rng); } int n, m, q; int ans[maxn]; int In[maxn], Out[maxn], h[maxn]; int st[maxn], _log[2 * maxn], Sl; vector<int> edges[maxn]; pair<int, int> sth[maxn]; pair<int, int> E[maxn], L[2 * maxn][18], P[maxn]; struct QR {ll u, v, x, y, id; } qr[maxn]; struct dl {int l, r, id; }; struct BIT { ll bit[maxn]; void init() { fi(i, 1, n + 5) bit[i] = 0; } void update(int x, ll val) { int l = In[x], r = Out[x] + 1; while(l < maxn) bit[l] += val, l += (l & -l); while(r < maxn) bit[r] -= val, r += (r & -r); } ll get(int x, ll ans = 0) { while(x > 0) ans += bit[x], x -= (x & -x); return ans; } } Bit; /// PRE DFS void pre_dfs(int u, int par, int k) { static int Time = 0; In[u] = ++Time, L[++Sl][0] = {k, u}; st[u] = Sl, h[u] = k; for(int v : edges[u]) if(v != par) { pre_dfs(v, u, k + 1); L[++Sl][0] = {k, u}; } Out[u] = Time; } void prepare() { fi(i, 1, Sl) _log[i] = __lg(i); fi(j, 1, _log[Sl]) fi(i, 1, Sl - (1 << j) + 1) L[i][j] = min(L[i][j - 1], L[i + (1 << (j - 1))][j - 1]); } int lca(int u, int v) { int l = st[u], r = st[v], j; if(l > r) swap(l, r); j = _log[r - l + 1]; return min(L[l][j], L[r - (1 << j) + 1][j]).second; } ll distW(int u, int v) { return Bit.get(In[u]) + Bit.get(In[v]) - 2 * Bit.get(In[lca(u, v)]); } /*----------------*/ void input() { cin >> n >> m >> q; fi(i, 1, n - 1) { int x, y; cin >> x >> y; edges[x].push_back(y), edges[y].push_back(x); E[i] = {x, y}; } fi(i, 1, m) { int id, val; cin >> id >> val; P[i] = {val, id}; } fi(i, 1, q) cin >> qr[i].u >> qr[i].v >> qr[i].x >> qr[i].y, qr[i].id = i; } void solve() { input(); pre_dfs(1, 0, 0), prepare(); fi(i, 1, m) { int u = In[E[P[i].second].first] > In[E[P[i].second].second] ? E[P[i].second].first : E[P[i].second].second; P[i].second = u; } sort(P + 1, P + 1 + m); vector<dl> store[maxn], tmp[maxn]; fi(i, 1, q) store[(1 + m) >> 1].push_back({1, m, i}); int Cnt = 0; while(Cnt < q) { Bit.init(); fi(i, 1, m) { Bit.update(P[i].second, P[i].first); for(auto [l, r, id] : store[i]) { ll u = qr[id].u, v = qr[id].v, Silver = qr[id].y; int mid = (l + r) >> 1; if(distW(u, v) <= Silver) l = mid + 1; else r = mid - 1; if(l > r) ans[qr[id].id] = r, ++Cnt; else tmp[(l + r) >> 1].push_back({l, r, id}); } } fi(i, 1, m) swap(tmp[i], store[i]), tmp[i].clear(); } // Log(P, 1, m) ; Bit.init(); fi(i, 1, q) sth[i] = {ans[i], i}; sort(sth + 1, sth + 1 + q); int j = 1; fi(i, 1, q) { while(j <= sth[i].first) Bit.update(P[j++].second, 1); int id = sth[i].second, u = qr[id].u, v = qr[id].v; ans[id] = - distW(u, v); } while(j <= m) Bit.update(P[j++].second, 1); fi(i, 1, q) { ans[i] = qr[i].x - (distW(qr[i].u, qr[i].v) + ans[i]); cout << max(ans[i], -1) << '\n'; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(Neco".inp", "r")) { freopen(Neco".inp", "r", stdin); freopen(Neco".out", "w", stdout); } int nTest = 1; // cin >> nTest; while(nTest--) { solve(); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

currencies.cpp:3:10: fatal error: bits/debug.hpp: No such file or directory
    3 | #include <bits/debug.hpp>
      |          ^~~~~~~~~~~~~~~~
compilation terminated.