#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fixbug false
//... READ INPUT
const int maxn = 1e5;
const int INF = 1e9;
const int maxm = 10000000;
vector<pair<int,int>> g[maxn+2];
ll d[maxn+2][2];
bool ex[maxn+2];
#define ii pair<ll,int>
#define fi first
#define se second
int travel_plan(int n , int m , int R[][2] , int L[] , int k , int P[]){
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]});
if (fixbug){
cout << R[i][0] << ' ' << R[i][1] << ' ' << L[i] << '\n';
}
}
priority_queue<ii,vector<ii>,greater<ii>> q;
for (int i = 0; i < n; ++i) d[i][0] = d[i][1] = INF;
ll ans = d[0][0];
for (int i = 0 ; i < k; ++i){
d[P[i]][0] = d[P[i]][1] = 0;
q.push({0 , P[i]});
}
while (q.size()){
int u = q.top().second; ll cost = q.top().first;
q.pop();
if (cost != d[u][0]) continue;
if (fixbug){
cout << "(DEBUG)\n";
cout << u << ' ' << cost << "\n";
}
for (auto & x : g[u]){
int v = x.first , w = x.second;
if (d[v][1] > cost + w){
d[v][0] = d[v][1];
d[v][1] = cost + w;
q.push({d[v][0] , v});
}
else
if (d[v][0] > cost + w) {
d[v][0] = cost + w;
q.push({d[v][0] , v});
}
}
}
if (fixbug){
cout << ans << '\n';
for (int i = 0; i < n; ++i) cout << d[i][0] << '\n';
}
return d[0][0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6488 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6488 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6556 KB |
Output is correct |
9 |
Correct |
2 ms |
6748 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
2 ms |
6744 KB |
Output is correct |
12 |
Correct |
3 ms |
6744 KB |
Output is correct |
13 |
Correct |
3 ms |
6748 KB |
Output is correct |
14 |
Correct |
1 ms |
6492 KB |
Output is correct |
15 |
Correct |
2 ms |
6492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Correct |
1 ms |
6492 KB |
Output is correct |
4 |
Correct |
1 ms |
6492 KB |
Output is correct |
5 |
Correct |
1 ms |
6488 KB |
Output is correct |
6 |
Correct |
1 ms |
6492 KB |
Output is correct |
7 |
Correct |
1 ms |
6492 KB |
Output is correct |
8 |
Correct |
1 ms |
6556 KB |
Output is correct |
9 |
Correct |
2 ms |
6748 KB |
Output is correct |
10 |
Correct |
1 ms |
6492 KB |
Output is correct |
11 |
Correct |
2 ms |
6744 KB |
Output is correct |
12 |
Correct |
3 ms |
6744 KB |
Output is correct |
13 |
Correct |
3 ms |
6748 KB |
Output is correct |
14 |
Correct |
1 ms |
6492 KB |
Output is correct |
15 |
Correct |
2 ms |
6492 KB |
Output is correct |
16 |
Correct |
277 ms |
46388 KB |
Output is correct |
17 |
Correct |
58 ms |
15560 KB |
Output is correct |
18 |
Correct |
77 ms |
16584 KB |
Output is correct |
19 |
Correct |
316 ms |
54564 KB |
Output is correct |
20 |
Correct |
171 ms |
39096 KB |
Output is correct |
21 |
Correct |
27 ms |
11472 KB |
Output is correct |
22 |
Incorrect |
212 ms |
35796 KB |
Output isn't correct |
23 |
Halted |
0 ms |
0 KB |
- |