#include "crocodile.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl
#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
int n,m,k;
vector<ii> al[100005];
ii w[100005];
bool vis[100005];
priority_queue<ii,vector<ii>,greater<ii> > pq;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
n=N,m=M,k=K;
memset(w,63,sizeof(w));
rep(x,0,m){
al[R[x][0]].push_back(ii(R[x][1],L[x]));
al[R[x][1]].push_back(ii(R[x][0],L[x]));
}
rep(x,0,k){
w[P[x]]=ii(0,0);
pq.push(ii(0,P[x]));
}
int weight,node;
while (!pq.empty()){
tie(weight,node)=pq.top(),pq.pop();
if (weight!=w[node].se || vis[node]) continue;
vis[node]=true;
if (node==0) return weight;
for (auto &it:al[node]) if (!vis[it.fi]){
if (w[it.fi].se>weight+it.se){
w[it.fi].se=weight+it.se;
if (w[it.fi].fi>w[it.fi].se) swap(w[it.fi].fi,w[it.fi].se);
pq.push(ii(w[it.fi].se,it.fi));
}
}
}
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4224 KB |
Output is correct |
2 |
Correct |
3 ms |
4224 KB |
Output is correct |
3 |
Correct |
3 ms |
4224 KB |
Output is correct |
4 |
Correct |
5 ms |
4352 KB |
Output is correct |
5 |
Correct |
5 ms |
4352 KB |
Output is correct |
6 |
Correct |
4 ms |
4352 KB |
Output is correct |
7 |
Correct |
4 ms |
4352 KB |
Output is correct |
8 |
Correct |
4 ms |
4352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4224 KB |
Output is correct |
2 |
Correct |
3 ms |
4224 KB |
Output is correct |
3 |
Correct |
3 ms |
4224 KB |
Output is correct |
4 |
Correct |
5 ms |
4352 KB |
Output is correct |
5 |
Correct |
5 ms |
4352 KB |
Output is correct |
6 |
Correct |
4 ms |
4352 KB |
Output is correct |
7 |
Correct |
4 ms |
4352 KB |
Output is correct |
8 |
Correct |
4 ms |
4352 KB |
Output is correct |
9 |
Correct |
5 ms |
4608 KB |
Output is correct |
10 |
Correct |
5 ms |
4344 KB |
Output is correct |
11 |
Correct |
5 ms |
4480 KB |
Output is correct |
12 |
Correct |
7 ms |
4992 KB |
Output is correct |
13 |
Correct |
9 ms |
5120 KB |
Output is correct |
14 |
Correct |
3 ms |
4352 KB |
Output is correct |
15 |
Correct |
5 ms |
4456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4224 KB |
Output is correct |
2 |
Correct |
3 ms |
4224 KB |
Output is correct |
3 |
Correct |
3 ms |
4224 KB |
Output is correct |
4 |
Correct |
5 ms |
4352 KB |
Output is correct |
5 |
Correct |
5 ms |
4352 KB |
Output is correct |
6 |
Correct |
4 ms |
4352 KB |
Output is correct |
7 |
Correct |
4 ms |
4352 KB |
Output is correct |
8 |
Correct |
4 ms |
4352 KB |
Output is correct |
9 |
Correct |
5 ms |
4608 KB |
Output is correct |
10 |
Correct |
5 ms |
4344 KB |
Output is correct |
11 |
Correct |
5 ms |
4480 KB |
Output is correct |
12 |
Correct |
7 ms |
4992 KB |
Output is correct |
13 |
Correct |
9 ms |
5120 KB |
Output is correct |
14 |
Correct |
3 ms |
4352 KB |
Output is correct |
15 |
Correct |
5 ms |
4456 KB |
Output is correct |
16 |
Correct |
634 ms |
85604 KB |
Output is correct |
17 |
Correct |
122 ms |
19948 KB |
Output is correct |
18 |
Correct |
144 ms |
21336 KB |
Output is correct |
19 |
Correct |
746 ms |
93340 KB |
Output is correct |
20 |
Correct |
358 ms |
69116 KB |
Output is correct |
21 |
Correct |
57 ms |
11640 KB |
Output is correct |
22 |
Correct |
429 ms |
65780 KB |
Output is correct |