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;
typedef pair<int,int> pii;
typedef pair<long long,int> pli;
const int MAXN=100005;
const long long INF=1e18;
vector<pii> adj[MAXN];
long long dist[MAXN];
priority_queue<pli,vector<pli>,greater<pli> > PQ;
bool keluar[MAXN];
int muncul[MAXN];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
for(int i=0;i<M;i++){
adj[R[i][0]].push_back({R[i][1],L[i]});
adj[R[i][1]].push_back({R[i][0],L[i]});
}
for(int i=0;i<N;i++)dist[i]=INF;
for(int i=0;i<K;i++){
dist[P[i]]=0;
keluar[P[i]]=true;
PQ.push({dist[P[i]],P[i]});
}
while(!PQ.empty()){
pii now=PQ.top();
PQ.pop();
muncul[now.second]++;
if(!keluar[now.second]){
if(muncul[now.second]!=2)continue;
}
else{
if(muncul[now.second]!=1)continue;
}
dist[now.second]=now.first;
for(auto nxt : adj[now.second]){
PQ.push({dist[now.second]+nxt.second,nxt.first});
}
}
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... |