#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
vector<int> vis(N,0);
vector<int> val(N,0);
priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;
vector<vector<int>> gr(N);
for(int i = 0; i < K; ++i){
pq.push({0,P[i]});
vis[P[i]] = 1;
}
for(int i = 0; i < M; ++i){
gr[R[i][0]].push_back(i);
gr[R[i][1]].push_back(i);
}
while(pq.size()){
auto x = pq.top();
pq.pop();
if(vis[x.second]++ == 1){
val[x.second] = x.first;
for(auto y : gr[x.second]){
pq.push({L[y]+x.first,R[y][0]^R[y][1]^x.second});
}
}
}
return val[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
360 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
360 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
444 KB |
Output is correct |
12 |
Correct |
7 ms |
980 KB |
Output is correct |
13 |
Correct |
6 ms |
1108 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
360 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
3 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
2 ms |
444 KB |
Output is correct |
12 |
Correct |
7 ms |
980 KB |
Output is correct |
13 |
Correct |
6 ms |
1108 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
356 KB |
Output is correct |
16 |
Correct |
978 ms |
59076 KB |
Output is correct |
17 |
Correct |
85 ms |
12108 KB |
Output is correct |
18 |
Correct |
106 ms |
13180 KB |
Output is correct |
19 |
Correct |
981 ms |
62984 KB |
Output is correct |
20 |
Correct |
616 ms |
53300 KB |
Output is correct |
21 |
Correct |
42 ms |
5076 KB |
Output is correct |
22 |
Correct |
530 ms |
36052 KB |
Output is correct |