This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0; i<n; ++i)
#define pb push_back
#define all(x) x.begin(),x.end()
#define pi pair<int,int>
#define f first
#define s second
const int N=1e5+55;
vector<pi> adj[N];
int ok[N];
int d[N];
int vis[N];
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {
forn(i,m) {
int u=r[i][0], v=r[i][1], w=l[i];
adj[u].pb({v,w}), adj[v].pb({u,w});
}
priority_queue<pi> q;
forn(i,k) q.push({0,p[i]}), vis[p[i]]=1;
while (q.size()) {
auto it=q.top(); q.pop();
int di=-it.f, u=it.s;
++vis[u];
if (vis[u]!=2) continue;
d[u]=di;
for(auto&e:adj[u]) {
int v=e.f, w=e.s;
q.push({-di-w,v});
}
}
return d[0];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |