#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(int i = (l); i < (r); i++)
#define snd second
#define fst first
#define V vector
#define pb push_back
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = 1e9 + 10;
struct edge{
int v, l;
};
V<V<edge>> adj;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
adj.resize(N);
FOR(i, 0, M) {
adj[R[i][0]].pb({R[i][1], L[i]});
adj[R[i][1]].pb({R[i][0], L[i]});
}
priority_queue<ii, vii, greater<ii>> q;
vi dist(N, INF);
vi vis(N, 0);
FOR(i,0,K) {
dist[P[i]] = 0;
vis[P[i]] = 1;
q.push({0, P[i]});
}
while(!q.empty()){
ii p = q.top(); q.pop();
int u = p.snd, d = p.fst;
//cout << u << " " << d << " " << vis[u] << endl;
if(!vis[u]){
vis[u] = 1;
continue;
}
if(dist[u] < d) continue;
dist[u] = d;
if(u == 0) return d;
for(edge e : adj[u]){
int v = e.v, l = e.l;
//cout<<v<<endl;
if(dist[v] > d+l){
//dist[v] = d+l;
q.push({d+l, v});
}
}
}
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
356 KB |
Output is correct |
3 |
Correct |
3 ms |
560 KB |
Output is correct |
4 |
Correct |
3 ms |
640 KB |
Output is correct |
5 |
Incorrect |
3 ms |
680 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
356 KB |
Output is correct |
3 |
Correct |
3 ms |
560 KB |
Output is correct |
4 |
Correct |
3 ms |
640 KB |
Output is correct |
5 |
Incorrect |
3 ms |
680 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
356 KB |
Output is correct |
3 |
Correct |
3 ms |
560 KB |
Output is correct |
4 |
Correct |
3 ms |
640 KB |
Output is correct |
5 |
Incorrect |
3 ms |
680 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |