#include "crocodile.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n, m;
vector<pair<int, int> > adj[100005];
priority_queue<ll> dist[100005];
ll ans[100005];
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
for (int i = 1; i <= M; i++) {
adj[R[i][0]].emplace_back(R[i][1], L[i]);
adj[R[i][1]].emplace_back(R[i][0], L[i]);
}
priority_queue<pair<ll, int> > pq;
memset(ans, 0x3f, sizeof(ans));
for (int i = 1; i <= K; i++) {
dist[P[i]].push(0);
dist[P[i]].push(0);
pq.push({ 0, P[i] });
ans[P[i]] = 0;
}
while (!pq.empty()) {
ll cost = -pq.top().first;
int now = pq.top().second;
pq.pop();
if (ans[now]< cost)continue;
for (auto &e : adj[now]) {
int there = e.first;
int weight = e.second;
dist[there].push(cost + weight);
while (dist[there].size() > 2)dist[there].pop();
if (dist[there].size() == 2 && dist[there].top() < ans[there]) {
ans[there] = dist[there].top();
pq.push({ -dist[there].top(),there });
}
}
}
return ans[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
6636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
6636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
6636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |