#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+10;
const ll INF = 1e15;
int n; ll d[N][2];
vector< pair<int,ll> > g[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[]) {
n = N_;
for(int i = 0; i < M; i++) {
g[R[i][0]].push_back({R[i][1], L[i]});
g[R[i][1]].push_back({R[i][0], L[i]});
}
for(int i = 0; i < n; i++) d[i][0] = d[i][1] = INF;
for(int i = 0; i < K; i++) {
d[P[i]][0] = d[P[i]][1] = 0;
q.push({0, P[i]});
}
while(!q.empty()) {
auto top = q.top(); q.pop();
int u = top.second; ll cw = top.first;
if(cw > d[u][1]) continue;
for(auto e : g[u]) {
if(cw + e.second <= d[e.first][0]) {
d[e.first][1] = d[e.first][0];
d[e.first][0] = cw + e.second;
q.push({d[e.first][1], e.first});
}
else if(cw + e.second < d[e.first][1]) {
d[e.first][1] = cw + e.second;
q.push({d[e.first][1], e.first});
}
}
} return d[0][1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2848 KB |
Output is correct |
3 |
Correct |
4 ms |
2896 KB |
Output is correct |
4 |
Correct |
4 ms |
2940 KB |
Output is correct |
5 |
Correct |
4 ms |
2956 KB |
Output is correct |
6 |
Correct |
4 ms |
2972 KB |
Output is correct |
7 |
Correct |
5 ms |
3128 KB |
Output is correct |
8 |
Correct |
4 ms |
3128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2848 KB |
Output is correct |
3 |
Correct |
4 ms |
2896 KB |
Output is correct |
4 |
Correct |
4 ms |
2940 KB |
Output is correct |
5 |
Correct |
4 ms |
2956 KB |
Output is correct |
6 |
Correct |
4 ms |
2972 KB |
Output is correct |
7 |
Correct |
5 ms |
3128 KB |
Output is correct |
8 |
Correct |
4 ms |
3128 KB |
Output is correct |
9 |
Correct |
6 ms |
3432 KB |
Output is correct |
10 |
Correct |
4 ms |
3432 KB |
Output is correct |
11 |
Correct |
5 ms |
3432 KB |
Output is correct |
12 |
Correct |
8 ms |
3832 KB |
Output is correct |
13 |
Correct |
7 ms |
3948 KB |
Output is correct |
14 |
Correct |
4 ms |
3948 KB |
Output is correct |
15 |
Correct |
5 ms |
3948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2848 KB |
Output is correct |
3 |
Correct |
4 ms |
2896 KB |
Output is correct |
4 |
Correct |
4 ms |
2940 KB |
Output is correct |
5 |
Correct |
4 ms |
2956 KB |
Output is correct |
6 |
Correct |
4 ms |
2972 KB |
Output is correct |
7 |
Correct |
5 ms |
3128 KB |
Output is correct |
8 |
Correct |
4 ms |
3128 KB |
Output is correct |
9 |
Correct |
6 ms |
3432 KB |
Output is correct |
10 |
Correct |
4 ms |
3432 KB |
Output is correct |
11 |
Correct |
5 ms |
3432 KB |
Output is correct |
12 |
Correct |
8 ms |
3832 KB |
Output is correct |
13 |
Correct |
7 ms |
3948 KB |
Output is correct |
14 |
Correct |
4 ms |
3948 KB |
Output is correct |
15 |
Correct |
5 ms |
3948 KB |
Output is correct |
16 |
Correct |
644 ms |
70592 KB |
Output is correct |
17 |
Correct |
104 ms |
70592 KB |
Output is correct |
18 |
Correct |
151 ms |
70592 KB |
Output is correct |
19 |
Correct |
779 ms |
79100 KB |
Output is correct |
20 |
Correct |
315 ms |
79100 KB |
Output is correct |
21 |
Correct |
51 ms |
79100 KB |
Output is correct |
22 |
Incorrect |
348 ms |
79100 KB |
Output isn't correct |