-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path707b.cpp
51 lines (47 loc) · 951 Bytes
/
707b.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int INF = 0x66554433;
inline void quick_IO(){
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
typedef struct edge{
int u;
int v;
int l;
edge(int a, int b, int c){
u = a;
v = b;
l = c;
}
} edge;
vector<edge> arr;
bool check[100001];
int main(){
quick_IO();
int n, m, k;
int u, v, l;
cin>>n>>m>>k;
for (int i = 0; i < m; ++i) {
cin>>u>>v>>l;
arr.emplace_back(u, v, l);
}
int answer = INF;
int temp;
for (int i = 0; i < k; ++i) {
cin>>temp;
check[temp] = true;
}
for(auto edge:arr){
if((check[edge.u] && !check[edge.v])||(check[edge.v]&&!check[edge.u])){
answer = min(answer, edge.l);
}
}
if(answer!=INF) cout<<answer;
else cout<<-1;
cout<<"\n";
return 0;
}