#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define pb push_back
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define INF 1023456789
#define LINF 1023456789123456789
#define lb(x,v) lower_bound(all(x),v)-x.begin()
#define disc(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,int> li;
#define maxn 100005
ll d[maxn],d2[maxn];
vector<ii> AL[maxn];
int travel_plan(int N,int M,int R[][2],int L[],int K,int P[]){
for(int i=0;i<M;++i){
int a=R[i][0],b=R[i][1],w=L[i];
AL[a].pb({b,w});
AL[b].pb({a,w});
}
priority_queue<li,vector<li>,greater<li>> pq;
fill(d,d+N,LINF);
fill(d2,d2+N,LINF);
for(int i=0;i<K;++i){
d[P[i]]=d2[P[i]]=0;
pq.push({0,P[i]});
}
while(!pq.empty()){
auto[cd,u]=pq.top();pq.pop();
if(cd!=d2[u])continue;
for(auto[v,w]:AL[u]){
ll nd=cd+w;
if(nd<d[v]){
if(d[v]<d2[v]){
d2[v]=d[v];
pq.push({d2[v],v});
}
d[v]=nd;
}
else if(nd<d2[v]){
d2[v]=nd;
pq.push({d2[v],v});
}
}
}
return d2[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2772 KB |
Output is correct |
5 |
Correct |
2 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2772 KB |
Output is correct |
8 |
Correct |
2 ms |
2772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2772 KB |
Output is correct |
5 |
Correct |
2 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2772 KB |
Output is correct |
8 |
Correct |
2 ms |
2772 KB |
Output is correct |
9 |
Correct |
3 ms |
2900 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
3 ms |
2772 KB |
Output is correct |
12 |
Correct |
4 ms |
3028 KB |
Output is correct |
13 |
Correct |
4 ms |
3028 KB |
Output is correct |
14 |
Correct |
3 ms |
2644 KB |
Output is correct |
15 |
Correct |
3 ms |
2772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2772 KB |
Output is correct |
5 |
Correct |
2 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2772 KB |
Output is correct |
8 |
Correct |
2 ms |
2772 KB |
Output is correct |
9 |
Correct |
3 ms |
2900 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
3 ms |
2772 KB |
Output is correct |
12 |
Correct |
4 ms |
3028 KB |
Output is correct |
13 |
Correct |
4 ms |
3028 KB |
Output is correct |
14 |
Correct |
3 ms |
2644 KB |
Output is correct |
15 |
Correct |
3 ms |
2772 KB |
Output is correct |
16 |
Correct |
397 ms |
42428 KB |
Output is correct |
17 |
Correct |
64 ms |
11212 KB |
Output is correct |
18 |
Correct |
84 ms |
12596 KB |
Output is correct |
19 |
Correct |
487 ms |
47624 KB |
Output is correct |
20 |
Correct |
266 ms |
36620 KB |
Output is correct |
21 |
Correct |
32 ms |
6480 KB |
Output is correct |
22 |
Correct |
270 ms |
32000 KB |
Output is correct |