#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 1e5+5;
vector<pii> adj[N];
short int vis[N];
int dis[N];
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]) {
priority_queue<pii, vector<pii>, greater<pii>> pq;
for(int i = 0; i < m; ++i)
adj[R[i][0]].pb({R[i][1], L[i]}), adj[R[i][1]].pb({R[i][0], L[i]});
for(int i = 0; i < k; ++i)
pq.push({0, P[i]}), vis[P[i]] = 1;
while(!pq.empty()){
int val = pq.top().ff, x = pq.top().ss;
pq.pop();
if(vis[x]==2)
continue;
vis[x]++;
if(vis[x]==1)
continue;
dis[x] = val;
tr(it, adj[x])
if(vis[it->ff] != 2)
pq.push({val+it->ss, it->ff});
}
return dis[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6480 KB |
Output is correct |
2 |
Correct |
2 ms |
6480 KB |
Output is correct |
3 |
Correct |
2 ms |
6480 KB |
Output is correct |
4 |
Correct |
2 ms |
6480 KB |
Output is correct |
5 |
Correct |
2 ms |
6480 KB |
Output is correct |
6 |
Correct |
2 ms |
6480 KB |
Output is correct |
7 |
Correct |
2 ms |
6480 KB |
Output is correct |
8 |
Correct |
2 ms |
6480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6480 KB |
Output is correct |
2 |
Correct |
2 ms |
6480 KB |
Output is correct |
3 |
Correct |
2 ms |
6480 KB |
Output is correct |
4 |
Correct |
2 ms |
6480 KB |
Output is correct |
5 |
Correct |
2 ms |
6480 KB |
Output is correct |
6 |
Correct |
2 ms |
6480 KB |
Output is correct |
7 |
Correct |
2 ms |
6480 KB |
Output is correct |
8 |
Correct |
2 ms |
6480 KB |
Output is correct |
9 |
Correct |
3 ms |
6736 KB |
Output is correct |
10 |
Correct |
2 ms |
6600 KB |
Output is correct |
11 |
Correct |
2 ms |
6492 KB |
Output is correct |
12 |
Correct |
5 ms |
6992 KB |
Output is correct |
13 |
Correct |
5 ms |
6992 KB |
Output is correct |
14 |
Correct |
2 ms |
6480 KB |
Output is correct |
15 |
Correct |
3 ms |
6480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
6480 KB |
Output is correct |
2 |
Correct |
2 ms |
6480 KB |
Output is correct |
3 |
Correct |
2 ms |
6480 KB |
Output is correct |
4 |
Correct |
2 ms |
6480 KB |
Output is correct |
5 |
Correct |
2 ms |
6480 KB |
Output is correct |
6 |
Correct |
2 ms |
6480 KB |
Output is correct |
7 |
Correct |
2 ms |
6480 KB |
Output is correct |
8 |
Correct |
2 ms |
6480 KB |
Output is correct |
9 |
Correct |
3 ms |
6736 KB |
Output is correct |
10 |
Correct |
2 ms |
6600 KB |
Output is correct |
11 |
Correct |
2 ms |
6492 KB |
Output is correct |
12 |
Correct |
5 ms |
6992 KB |
Output is correct |
13 |
Correct |
5 ms |
6992 KB |
Output is correct |
14 |
Correct |
2 ms |
6480 KB |
Output is correct |
15 |
Correct |
3 ms |
6480 KB |
Output is correct |
16 |
Correct |
419 ms |
70684 KB |
Output is correct |
17 |
Correct |
63 ms |
16564 KB |
Output is correct |
18 |
Correct |
68 ms |
18100 KB |
Output is correct |
19 |
Correct |
437 ms |
73144 KB |
Output is correct |
20 |
Correct |
318 ms |
64408 KB |
Output is correct |
21 |
Correct |
28 ms |
10320 KB |
Output is correct |
22 |
Correct |
304 ms |
49736 KB |
Output is correct |