#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
typedef pair<int, int> ii;
typedef vector<ii> vi;
typedef vector<vi> vvi;
const int MAXN = 111111;
int visit[MAXN];
vvi linkd;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
vvi(N).swap(linkd);
memset( visit, 0, sizeof visit);
for(int i=0; i<M; i++){
linkd[ R[i][0] ].push_back( { R[i][1], L[i] } );
linkd[ R[i][1] ].push_back( { R[i][0], L[i] } );
} priority_queue<ii> pq;
for(int i=0; i<K; i++) pq.push( { 0, P[i] } ), visit[ P[i] ] = 1;
while(!pq.empty()){
int here = pq.top().second, d = -pq.top().first; pq.pop();
if( ++visit[here] == 1 ) continue;
if( here == 0 ) return d;
for(auto it : linkd[here])
pq.push( { -d-it.second, it.first } );
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
119536 KB |
Output is correct |
2 |
Correct |
0 ms |
119536 KB |
Output is correct |
3 |
Memory limit exceeded |
1181 ms |
262144 KB |
Memory limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
119800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Memory limit exceeded |
837 ms |
262144 KB |
Memory limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |