#include "crocodile.h"
#include <bits/stdc++.h>
#define dbg(x) cout << #x << ": " << x << endl;
#define raya cout << "===========================" << endl;
using namespace std;
const int N = 1e5+5;
int n, m;
bool ext[N];
vector<pair<int,int>> g[N];
int f(int i, int p=-1){
if((int) g[i].size() == 1){
if(ext[i]){
return 0;
}
return 1e9;
}
set<int> st;
for(auto v : g[i]){
if(v.first != p){
st.insert(f(v.first, i)+v.second);
}
}
st.erase(st.begin());
return *st.begin();
}
int travel_plan(int nn, int mm, int R[][2], int L[], int K, int P[]){
n = nn;
m = mm;
for(int i=0; i<K; ++i){
ext[P[i]] = 1;
}
for(int i=0; i<m; ++i){
g[R[i][0]].push_back({R[i][1], L[i]});
g[R[i][1]].push_back({R[i][0], L[i]});
}
return f(0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2656 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
6 ms |
2672 KB |
Output is correct |
5 |
Incorrect |
4 ms |
2644 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2656 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
6 ms |
2672 KB |
Output is correct |
5 |
Incorrect |
4 ms |
2644 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2656 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
6 ms |
2672 KB |
Output is correct |
5 |
Incorrect |
4 ms |
2644 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |