이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "crocodile.h"
#include <bits/stdc++.h>
#define xx first
#define yy second
using namespace std;
long long int typedef li;
vector<vector<pair<int,int>>> g(100003);
li dp[100003]; bitset<100003> vis,izlaz;
int travel_plan(int n, int m, int R[][2], int L[], int K, int P[])
{
for (int i=0;i<m;i++)
{
g[R[i][0]].push_back({L[i],R[i][1]});
g[R[i][1]].push_back({L[i],R[i][0]});
}
priority_queue<pair<li,int>,vector<pair<li,int>>,greater<pair<li,int>>> pq;
for (int i=0;i<K;i++) pq.push({0,P[i]}),vis[P[i]]=1;
while (!pq.empty())
{
li d=pq.top().xx;
int p=pq.top().yy;
pq.pop();
if (dp[p]) continue;
if (izlaz[p]) continue;
if (vis[p])
{
dp[p]=d,izlaz[p]=1;
for (auto it : g[p]) pq.push({dp[p]+it.xx,it.yy});
}
else vis[p]=1;
}
return dp[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... |