This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int, ll>
#define F first
#define S second
const int N = 200005;
const int mod = 1e9+7;
vector<pii> a[N];
int DFS(int node, int par){
ll mn1 = LONG_MAX, mn2 = LONG_MAX;
for(pii i : a[node]){
if(i.F == par) continue;
ll cur = DFS(i.F, node) + i.S;
if(cur <= mn1){
mn2 = mn1;
mn1 = cur;
}
else if(cur < mn2) mn2 = cur;
}
if(mn1 == LONG_MAX || mn2 == LONG_MAX) return 0;
return mn2;
}
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
for(int i = 0; i < m; i++){
int u = r[i][0];
int v = r[i][1];
ll w = l[i];
a[u].pb({v, w});
a[v].pb({u, w});
}
return DFS(0, 0);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |