Tên đăng nhập Điểm ▾ Bài tập Giới thiệu
35401 0 0
35401 0 0
35401 0 0

35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401
LeeN
Trần Lê Nguyễn
0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0

include <bits/stdc++.h>

using namespace std;
queue<int> s;
vector<int> a[100005];
int n, m, k, p, res, b[1000][1000];
bool Free[100005], check[1000][1000];
void bfs(int u){
Free[u]=true;
s.push(u);
while(!s.empty()){
int u=s.front();
s.pop();
for(int v=0; v<a[u].size(); v++){ if(!Free[a[u][v]] && b[u][a[u][v]]>=p){
s.push(a[u][v]);
Free[a[u][v]]=true;
}
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
p=INT_MAX;
cin>>n>>m>>k;
for(int i=1; i<=k; i++){
int x;
cin>>x;
p=min(p, x);
}
//cout<<p<<" ";
for(int i=1; i<=m; i++){
int u, v, w;
cin>>u>>v>>w;
if(!check[u][v]){
check[u][v]=true;
a[u].push_back(v);
a[v].push_back(u);
}
if(b[u][v]<=w & b[v][u]<=w){
b[u][v]=w;
b[v][u]=w;
}
}
for(int i=1; i<=n; i++)
if(!Free[i]){
res++;
bfs(i);
}
cout<<res;
return 0;
}

35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0

mm

35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401
minecraftzkai
Thành Đạt
0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401
Duchz 953
Đặng Minh Đức, Phú Thọ
0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401
mahn_tr2007 891
Trần Đình Mạnh, Điện Biên
0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401
nnh1510 1033
Nguyễn Ngân Hương, Phú Thọ
0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401 0 0
35401
rakkoon69 1911
Lê Hữu Hòa, Bà Rịa – Vũng Tàu
0 0

uoc gi

35401
KhacDaiNguyen 947
Nguyễn Khắc Đại, Nghệ An
0 0
35401 0 0
35401 0 0