#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<vector<int>>> edg;
map<int, int> mp;
vector<int> vis;
int dfs(int idx) {
vector<int> v;
for (auto &i : edg[idx]) {
if (!vis[i[0]]) {
vis[i[0]] = 1;
int e = i[1];
if (!mp[i[0]]) {
e += dfs(i[0]);
}
v.push_back(e);
}
}
sort(v.begin(), v.end());
return v[1];
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
edg.resize(N);
vis.resize(N);
for (int i = 0; i < M; i++) {
edg[R[i][0]].push_back({R[i][1], L[i]});
edg[R[i][1]].push_back({R[i][0], L[i]});
}
for (int i = 0; i < K ; i++) {
mp[P[i]]++;
}
vis[0] = 1;
return dfs(0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
568 KB |
Output is correct |
9 |
Runtime error |
5 ms |
2004 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
568 KB |
Output is correct |
9 |
Runtime error |
5 ms |
2004 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |