Submission #1000357

#TimeUsernameProblemLanguageResultExecution timeMemory
1000357sofijavelkovskaClosing Time (IOI23_closing)C++17
8 / 100
68 ms22228 KiB
//#include "closing.h" #include <bits/stdc++.h> using namespace std; const long long INF=1e18; int max_score(int N, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W) { int n=N, s1=X, s2=Y; long long k=K; vector<pair<int, int> > adj[n]; for (int i=0; i<n-1; i++) { adj[U[i]].push_back({V[i], W[i]}); adj[V[i]].push_back({U[i], W[i]}); } long long dist[n]; for (int i=0; i<n; i++) dist[i]=INF; dist[s1]=0; dist[s2]=0; bool visited[n]={false}; priority_queue<pair<long long, int> > pq; pq.push({0, s1}); pq.push({0, s2}); long long left=k; int total=0; while (!pq.empty()) { long long d=-pq.top().first; int x=pq.top().second; pq.pop(); if (visited[x]) continue; visited[x]=true; if (left<d) break; left=left-d; total=total+1; for (auto edge : adj[x]) { int y=edge.first; int dt=edge.second; if (d+dt<dist[y]) { dist[y]=d+dt; pq.push({-dist[y], y}); } } } return total; }
#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...