#include<bits/stdc++.h>
#include"crocodile.h"
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int sz = 1e5+5;
vector<pii>g[sz];
int par[sz], usize[sz], vis[sz], e[sz], k = 0, i;
ll dist[sz], maxx = 0;
void makeset(ll v)
{
usize[v] = 1;
par[v] = v;
}
ll findpar(ll v)
{
if(par[v] == v)
return v;
return par[v] = findpar(v);
}
void dfs(ll node)
{
vis[node] = 1;
for(auto [u, w] : g[node])
{
if(vis[u])
continue;
dist[u] = dist[node] + w;
if(e[u])
maxx = max(maxx, dist[u]);
}
}
void unionsets(ll a, ll b)
{
a = findpar(a);
b = findpar(b);
if(a != b)
{
k = 1;
if(usize[a] < usize[b])
swap(a, b);
par[b] = a;
usize[a] += usize[b];
}
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
maxx = 0;
for(i = 0; i < N; i++)
makeset(i);
for(i = 0; i < M; i++)
{
k = 0;
ll x = R[i][0], y = R[i][1];
unionsets(x, y);
if(k == 1)
{
g[R[i][0]].pb({R[i][1], L[i]});
g[R[i][1]].pb({R[i][0], L[i]});
}
}
for(i = 0; i < K; i++)
e[P[i]] = 1;
dist[0] = 0;
dfs(0);
return maxx;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
160 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
160 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
160 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |