#include <bits/stdc++.h>
using namespace std;
#include "crocodile.h"
#define pb push_back
#define fi first
#define se second
const int nax=1e5+5;
vector<pair<int,int>> adj[nax];
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]].pb({R[i][1],L[i]});
adj[R[i][1]].pb({R[i][0],L[i]});
}
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
int vis[N];
memset(vis,0,sizeof vis);
for (int i = 0; i < K; ++i)
{
pq.push({0,P[i]});
vis[i]++;
}
while(!pq.empty()){
pair<int,int> node=pq.top();
pq.pop();
if(vis[node.se]++==1){
if(node.se==0) return node.fi;
for(auto u:adj[node.fi]){
pq.push({u.se+node.fi,u.fi});
}
}
}
return N;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
6748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
6748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
6748 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |