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<bits/stdc++.h>
#include "crocodile.h"
using namespace std;
const int MAX_SOM=100*1000+5,INFINI=1000*1000*1000+5;
int nbSom,nbAre,nbExit;
int dist[MAX_SOM];
int meil[MAX_SOM][2];
vector<pair<int,int>> adja[MAX_SOM];
priority_queue<pair<int,int>> possi;
void ajout(int pos,int val) {
if (val<meil[pos][1]) {
meil[pos][1]=val;
if (meil[pos][0]>meil[pos][1]) {
swap(meil[pos][0],meil[pos][1]);
}
possi.push({-meil[pos][1],pos});
}
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
nbSom=N;
nbAre=M;
nbExit=K;
for (int i=0;i<nbSom;i++) {
meil[i][0]=INFINI;
meil[i][1]=INFINI;
dist[i]=-1;
}
for (int i=0;i<nbAre;i++) {
adja[R[i][0]].push_back({R[i][1],L[i]});
adja[R[i][1]].push_back({R[i][0],L[i]});
}
for (int i=0;i<nbExit;i++) {
possi.push({0,P[i]});
}
int distCour,pos;
while (!possi.empty()) {
distCour=-possi.top().first;
pos=possi.top().second;
possi.pop();
if (dist[pos]==-1) {
dist[pos]=distCour;
for (auto i:adja[pos]) {
ajout(i.first,distCour+i.second);
}
}
}
return dist[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... |