#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<int, int> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ld> vd;
typedef vector<long long> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define nl endl
#define S second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;
#include "crocodile.h"
vector<vpi> paths(1e5+6,vpi());
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
FOR(i,0,M){
paths[R[i][0]].pb({R[i][1],L[i]});
paths[R[i][1]].pb({R[i][0],L[i]});
}
vi visited(N,0);
vl dist1(N,1e18);
vl dist2(N,1e18);
priority_queue<pi> pq;
FOR(i,0,K){
pq.push({0,P[i]});
dist1[P[i]] = 0;
dist2[P[i]] = 0;
}
while(!pq.empty()){
int node = pq.top().F;
ll dist = pq.top().S;
pq.pop();
if(visited[node])continue;
visited[node] = 1;
for(auto edge:paths[node]){
ll temp = -dist + edge.S;
if(dist1[edge.F] > temp){
dist2[edge.F] = dist1[edge.F];
dist1[edge.F] = temp;
}
else if(dist2[edge.F] > temp){
dist2[edge.F] = temp;
}
pq.push({-dist2[edge.F],edge.F});
}
}
// FOR(i,0,N){
// cout << i << " " << dist[i] << endl;
// }
return dist2[0];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
13656 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
13656 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
13656 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |