#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
typedef pair<int,int>pii;
vector<pii>adj[100005];
int dfs(int index, int par){
vector<int>v;
for(auto it:adj[index]){
if(it.first==par) continue;
v.push_back(dfs(it.first,index)+it.second);
}
sort(v.begin(),v.end());
if(v.size()>=2){
return v[1];
}
else return 0;
}
int travel_plan(int n, int m, int r[][2], int w[], int k, int p[]){
for(int x=0;x<m;x++){
adj[r[x][0]].push_back({r[x][1],w[x]});
adj[r[x][1]].push_back({r[x][0],w[x]});
}
return dfs(0,-1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
1 ms |
6748 KB |
Output is correct |
3 |
Correct |
2 ms |
6748 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
2 ms |
6748 KB |
Output is correct |
6 |
Correct |
2 ms |
6748 KB |
Output is correct |
7 |
Correct |
2 ms |
6788 KB |
Output is correct |
8 |
Correct |
2 ms |
6784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
1 ms |
6748 KB |
Output is correct |
3 |
Correct |
2 ms |
6748 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
2 ms |
6748 KB |
Output is correct |
6 |
Correct |
2 ms |
6748 KB |
Output is correct |
7 |
Correct |
2 ms |
6788 KB |
Output is correct |
8 |
Correct |
2 ms |
6784 KB |
Output is correct |
9 |
Runtime error |
166 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6748 KB |
Output is correct |
2 |
Correct |
1 ms |
6748 KB |
Output is correct |
3 |
Correct |
2 ms |
6748 KB |
Output is correct |
4 |
Correct |
1 ms |
6748 KB |
Output is correct |
5 |
Correct |
2 ms |
6748 KB |
Output is correct |
6 |
Correct |
2 ms |
6748 KB |
Output is correct |
7 |
Correct |
2 ms |
6788 KB |
Output is correct |
8 |
Correct |
2 ms |
6784 KB |
Output is correct |
9 |
Runtime error |
166 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Halted |
0 ms |
0 KB |
- |