#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
int k;
vector<pair<int, int>> AdjList[100005];
bitset<100005> visited;
int p[100005];
int dfs(int u) {
if(p[u]) return 0;
visited[u] = 1;
vector<int> pos = {1<<30, 1<<30};
for(auto v: AdjList[u])
if(!visited[v.second])
pos.push_back(min(1<<30, dfs(v.second)+v.first));
sort(pos.begin(), pos.end());
return pos[1];
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
k = K;
for(int i = 0; i < K; i++)
p[P[i]]=1;
for(int i = 0; i < M; i++) {
AdjList[R[i][0]].push_back({L[i], R[i][1]});
AdjList[R[i][1]].push_back({L[i], R[i][0]});
}
return dfs(0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2708 KB |
Output is correct |
3 |
Correct |
4 ms |
2888 KB |
Output is correct |
4 |
Correct |
6 ms |
2888 KB |
Output is correct |
5 |
Correct |
5 ms |
2888 KB |
Output is correct |
6 |
Correct |
5 ms |
2952 KB |
Output is correct |
7 |
Correct |
6 ms |
2976 KB |
Output is correct |
8 |
Correct |
6 ms |
2976 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2708 KB |
Output is correct |
3 |
Correct |
4 ms |
2888 KB |
Output is correct |
4 |
Correct |
6 ms |
2888 KB |
Output is correct |
5 |
Correct |
5 ms |
2888 KB |
Output is correct |
6 |
Correct |
5 ms |
2952 KB |
Output is correct |
7 |
Correct |
6 ms |
2976 KB |
Output is correct |
8 |
Correct |
6 ms |
2976 KB |
Output is correct |
9 |
Incorrect |
7 ms |
3152 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2708 KB |
Output is correct |
3 |
Correct |
4 ms |
2888 KB |
Output is correct |
4 |
Correct |
6 ms |
2888 KB |
Output is correct |
5 |
Correct |
5 ms |
2888 KB |
Output is correct |
6 |
Correct |
5 ms |
2952 KB |
Output is correct |
7 |
Correct |
6 ms |
2976 KB |
Output is correct |
8 |
Correct |
6 ms |
2976 KB |
Output is correct |
9 |
Incorrect |
7 ms |
3152 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |