#include "crocodile.h"
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
int travel_plan(int n, int m, int R[][2], int L[], int k, int p[])
{
vector <vector <pii> > g(n);
priority_queue <pii> pq;
for(int i = 0; i < m; i++){
int u = R[i][0];
int v = R[i][1];
int l = L[i];
g[v].pb({u, l});
g[u].pb({v, l});
}
int d[n + 1][2];
for(int i = 0; i < n; i++)
d[i][0] = d[i][1] = 1e9 + 1;
for(int i = 0; i < k; i++){
pq.push({0, p[i]});
d[p[i]][0] = d[p[i]][1] = 0;
}
vector <bool> used(n + 1, false);
while(!pq.empty()){
int v = pq.top().s; pq.pop();
if(used[v]) continue;
used[v] = true;
for(auto x : g[v]){
int to = x.f;
int len = x.s;
if(d[v][1] + len < d[to][1]){
d[to][1] = d[v][1] + len;
if(d[to][0] > d[to][1]) swap(d[to][1], d[to][0]);
if(d[to][1] != 1e9 + 1)pq.push({-d[to][1], to});
}
}
}
return d[0][1];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
3 ms |
724 KB |
Output is correct |
13 |
Correct |
3 ms |
852 KB |
Output is correct |
14 |
Correct |
1 ms |
308 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
596 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
3 ms |
724 KB |
Output is correct |
13 |
Correct |
3 ms |
852 KB |
Output is correct |
14 |
Correct |
1 ms |
308 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
299 ms |
56004 KB |
Output is correct |
17 |
Correct |
59 ms |
13744 KB |
Output is correct |
18 |
Correct |
64 ms |
15180 KB |
Output is correct |
19 |
Correct |
349 ms |
61016 KB |
Output is correct |
20 |
Correct |
218 ms |
46948 KB |
Output is correct |
21 |
Correct |
28 ms |
5996 KB |
Output is correct |
22 |
Correct |
230 ms |
44288 KB |
Output is correct |