#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 |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
5004 KB |
Output is correct |
3 |
Correct |
3 ms |
4940 KB |
Output is correct |
4 |
Correct |
4 ms |
5080 KB |
Output is correct |
5 |
Correct |
4 ms |
5068 KB |
Output is correct |
6 |
Correct |
3 ms |
5068 KB |
Output is correct |
7 |
Correct |
4 ms |
5016 KB |
Output is correct |
8 |
Correct |
4 ms |
5016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
5004 KB |
Output is correct |
3 |
Correct |
3 ms |
4940 KB |
Output is correct |
4 |
Correct |
4 ms |
5080 KB |
Output is correct |
5 |
Correct |
4 ms |
5068 KB |
Output is correct |
6 |
Correct |
3 ms |
5068 KB |
Output is correct |
7 |
Correct |
4 ms |
5016 KB |
Output is correct |
8 |
Correct |
4 ms |
5016 KB |
Output is correct |
9 |
Runtime error |
174 ms |
262148 KB |
Execution killed with signal 9 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4940 KB |
Output is correct |
2 |
Correct |
3 ms |
5004 KB |
Output is correct |
3 |
Correct |
3 ms |
4940 KB |
Output is correct |
4 |
Correct |
4 ms |
5080 KB |
Output is correct |
5 |
Correct |
4 ms |
5068 KB |
Output is correct |
6 |
Correct |
3 ms |
5068 KB |
Output is correct |
7 |
Correct |
4 ms |
5016 KB |
Output is correct |
8 |
Correct |
4 ms |
5016 KB |
Output is correct |
9 |
Runtime error |
174 ms |
262148 KB |
Execution killed with signal 9 |
10 |
Halted |
0 ms |
0 KB |
- |