#include "crocodile.h"
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
using namespace std;
const ll INF=1e18, N=100005;
pair<ll, ll> D[N];
vector<pair<int, ll> > v[N];
priority_queue <pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > q;
int travel_plan(int n, int m, int R[][2], int L[], int k, int p[]){
for (int i=0; i<m; i++)
v[R[i][0]].push_back({R[i][1], L[i]}),
v[R[i][1]].push_back({R[i][0], L[i]});
for (int i=0; i<n; i++)D[i]={INF, INF};
for (int i=0; i<k; i++)D[p[i]]={0, 0},q.push({0, p[i]});
while(!q.empty()){
long long d=q.top().F;
int x=q.top().S;
q.pop();
if(d!=D[x].F)continue;
for (auto [y, l] : v[x]){
if(D[y].F>d+l){
D[y].F=d+l;
if(D[y].F<D[y].S)swap(D[y].F, D[y].S);
if(D[y].F!=INF)q.push({D[y].F, y});
}
}
}
return D[0].F;
}
Compilation message
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:28:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
28 | for (auto [y, l] : v[x]){
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2668 KB |
Output is correct |
2 |
Correct |
2 ms |
2668 KB |
Output is correct |
3 |
Correct |
2 ms |
2816 KB |
Output is correct |
4 |
Correct |
3 ms |
2816 KB |
Output is correct |
5 |
Correct |
3 ms |
2796 KB |
Output is correct |
6 |
Correct |
2 ms |
2796 KB |
Output is correct |
7 |
Correct |
3 ms |
2796 KB |
Output is correct |
8 |
Correct |
3 ms |
2796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2668 KB |
Output is correct |
2 |
Correct |
2 ms |
2668 KB |
Output is correct |
3 |
Correct |
2 ms |
2816 KB |
Output is correct |
4 |
Correct |
3 ms |
2816 KB |
Output is correct |
5 |
Correct |
3 ms |
2796 KB |
Output is correct |
6 |
Correct |
2 ms |
2796 KB |
Output is correct |
7 |
Correct |
3 ms |
2796 KB |
Output is correct |
8 |
Correct |
3 ms |
2796 KB |
Output is correct |
9 |
Correct |
5 ms |
3180 KB |
Output is correct |
10 |
Correct |
2 ms |
2668 KB |
Output is correct |
11 |
Correct |
4 ms |
2924 KB |
Output is correct |
12 |
Correct |
7 ms |
3436 KB |
Output is correct |
13 |
Correct |
5 ms |
3564 KB |
Output is correct |
14 |
Correct |
2 ms |
2796 KB |
Output is correct |
15 |
Correct |
3 ms |
2796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2668 KB |
Output is correct |
2 |
Correct |
2 ms |
2668 KB |
Output is correct |
3 |
Correct |
2 ms |
2816 KB |
Output is correct |
4 |
Correct |
3 ms |
2816 KB |
Output is correct |
5 |
Correct |
3 ms |
2796 KB |
Output is correct |
6 |
Correct |
2 ms |
2796 KB |
Output is correct |
7 |
Correct |
3 ms |
2796 KB |
Output is correct |
8 |
Correct |
3 ms |
2796 KB |
Output is correct |
9 |
Correct |
5 ms |
3180 KB |
Output is correct |
10 |
Correct |
2 ms |
2668 KB |
Output is correct |
11 |
Correct |
4 ms |
2924 KB |
Output is correct |
12 |
Correct |
7 ms |
3436 KB |
Output is correct |
13 |
Correct |
5 ms |
3564 KB |
Output is correct |
14 |
Correct |
2 ms |
2796 KB |
Output is correct |
15 |
Correct |
3 ms |
2796 KB |
Output is correct |
16 |
Correct |
578 ms |
83168 KB |
Output is correct |
17 |
Correct |
82 ms |
17644 KB |
Output is correct |
18 |
Correct |
105 ms |
20096 KB |
Output is correct |
19 |
Correct |
680 ms |
89436 KB |
Output is correct |
20 |
Correct |
311 ms |
68076 KB |
Output is correct |
21 |
Correct |
41 ms |
10092 KB |
Output is correct |
22 |
Incorrect |
334 ms |
64236 KB |
Output isn't correct |