제출 #840047

#제출 시각아이디문제언어결과실행 시간메모리
840047socpite봉쇄 시간 (IOI23_closing)C++17
8 / 100
73 ms18652 KiB
#include "closing.h" #include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const long long INF = 1e18; int vis[maxn]; long long dep[maxn]; vector<pair<int, int>> g[maxn]; int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W) { for (int i = 0; i < N; i++) g[i].clear(); for (int i = 0; i < N - 1; i++) { g[U[i]].push_back({V[i], W[i]}); g[V[i]].push_back({U[i], W[i]}); } for (int i = 0; i < N; i++) dep[i] = INF; priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq; pq.push({0, X}); pq.push({0, Y}); dep[X] = 0; dep[Y] = 0; long long ans = 0; while (!pq.empty()) { auto x = pq.top(); // cout << "among " << x.first << " " << x.second << endl; pq.pop(); if (x.first > K) break; K -= x.first; ans++; for (auto v : g[x.second]) { if (dep[v.first] <= x.first + v.second) continue; dep[v.first] = x.first + v.second; pq.push({dep[v.first], v.first}); } } 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...