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<vector>
#include<queue>
std::vector<std::pair<int,int> > G[100000];
std::priority_queue<std::pair<int,int> > PQ;
std::pair<int,int> P;
int D[100000];
int travel_plan(int N,int M,int R[][2],int L[],int K,int X[])
{
int i;
for(i=0;i<N;i++)
{
G[i].clear();
D[i]=-1;
}
for(i=0;i<M;i++)
{
G[R[i][0]].push_back(std::make_pair(R[i][1],L[i]));
G[R[i][1]].push_back(std::make_pair(R[i][0],L[i]));
}
for(i=0;i<K;i++)
{
D[X[i]]=-2;
PQ.push(std::make_pair(0,X[i]));
}
while(!PQ.empty())
{
P=PQ.top();
PQ.pop();
if(D[P.second]>=0)continue;
if(D[P.second]==-1)
{
D[P.second]=-2;
continue;
}
D[P.second]=-P.first;
for(i=0;i<G[P.second].size();i++)PQ.push(std::make_pair(P.first-G[P.second][i].second,G[P.second][i].first));
}
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... |