#include "crocodile.h"
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#define LL long long
#define pll pair<LL,LL>
#define pii pair<int,int>
#define ff first
#define ss second
#define INF 1e18
using namespace std;
int n;
vector<pii> edge[111111];
bool is_esc[111111];
pll dist[111111];
priority_queue<pll,vector<pll>,greater<pll>> pq;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
n=N;
for(int i=0;i<M;i++){
edge[R[i][0]].push_back({R[i][1],L[i]});
edge[R[i][1]].push_back({R[i][0],L[i]});
}
for(int i=0;i<K;i++) is_esc[P[i]]=1;
for(int i=0;i<N;i++){
if(is_esc[i]) pq.push({0,i});
else dist[i].ff=dist[i].ss=INF;
}
while(!pq.empty()){
pll p=pq.top(); pq.pop();
if(p.ff!=dist[p.ss].ss) continue;
for(pii u:edge[p.ss]){
if(dist[u.ff].ff>dist[p.ss].ss+u.ss){
bool sta=(dist[u.ff].ff==dist[u.ff].ss);
dist[u.ff].ss=dist[u.ff].ff;
dist[u.ff].ff=dist[p.ss].ss+u.ss;
if(!sta && dist[u.ff].ss!=INF) pq.push({dist[u.ff].ss,u.ff});
}
else if(dist[u.ff].ss>dist[p.ss].ss+u.ss){
dist[u.ff].ss=dist[p.ss].ss+u.ss;
pq.push({dist[u.ff].ss,u.ff});
}
}
}
return dist[0].ss;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2936 KB |
Output is correct |
2 |
Correct |
3 ms |
2940 KB |
Output is correct |
3 |
Correct |
3 ms |
2936 KB |
Output is correct |
4 |
Correct |
4 ms |
3064 KB |
Output is correct |
5 |
Correct |
4 ms |
3064 KB |
Output is correct |
6 |
Correct |
4 ms |
3068 KB |
Output is correct |
7 |
Correct |
4 ms |
3064 KB |
Output is correct |
8 |
Correct |
4 ms |
3064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2936 KB |
Output is correct |
2 |
Correct |
3 ms |
2940 KB |
Output is correct |
3 |
Correct |
3 ms |
2936 KB |
Output is correct |
4 |
Correct |
4 ms |
3064 KB |
Output is correct |
5 |
Correct |
4 ms |
3064 KB |
Output is correct |
6 |
Correct |
4 ms |
3068 KB |
Output is correct |
7 |
Correct |
4 ms |
3064 KB |
Output is correct |
8 |
Correct |
4 ms |
3064 KB |
Output is correct |
9 |
Correct |
5 ms |
3320 KB |
Output is correct |
10 |
Correct |
4 ms |
2936 KB |
Output is correct |
11 |
Correct |
4 ms |
3064 KB |
Output is correct |
12 |
Correct |
7 ms |
3476 KB |
Output is correct |
13 |
Correct |
6 ms |
3448 KB |
Output is correct |
14 |
Correct |
4 ms |
3004 KB |
Output is correct |
15 |
Correct |
4 ms |
3064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2936 KB |
Output is correct |
2 |
Correct |
3 ms |
2940 KB |
Output is correct |
3 |
Correct |
3 ms |
2936 KB |
Output is correct |
4 |
Correct |
4 ms |
3064 KB |
Output is correct |
5 |
Correct |
4 ms |
3064 KB |
Output is correct |
6 |
Correct |
4 ms |
3068 KB |
Output is correct |
7 |
Correct |
4 ms |
3064 KB |
Output is correct |
8 |
Correct |
4 ms |
3064 KB |
Output is correct |
9 |
Correct |
5 ms |
3320 KB |
Output is correct |
10 |
Correct |
4 ms |
2936 KB |
Output is correct |
11 |
Correct |
4 ms |
3064 KB |
Output is correct |
12 |
Correct |
7 ms |
3476 KB |
Output is correct |
13 |
Correct |
6 ms |
3448 KB |
Output is correct |
14 |
Correct |
4 ms |
3004 KB |
Output is correct |
15 |
Correct |
4 ms |
3064 KB |
Output is correct |
16 |
Correct |
549 ms |
58744 KB |
Output is correct |
17 |
Correct |
81 ms |
14840 KB |
Output is correct |
18 |
Correct |
115 ms |
16248 KB |
Output is correct |
19 |
Correct |
730 ms |
64376 KB |
Output is correct |
20 |
Correct |
294 ms |
49912 KB |
Output is correct |
21 |
Correct |
40 ms |
8184 KB |
Output is correct |
22 |
Correct |
319 ms |
46568 KB |
Output is correct |