1 条题解
-
0
#include<bits/stdc++.h> using namespace std; const int N=3e4+10; vector<int>G[N]; bool vis[N]; int ans; void dfs(int x){ ans++; vis[x]=true; for(int y:G[x]) if(!vis[y]) dfs(y); } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m,k;cin>>n>>m>>k; for(int i=1,x,y;i<=m;i++){ cin>>x>>y; G[x].push_back(y); G[y].push_back(x); } memset(vis,false,sizeof(vis)); for(int i=1,x;i<=k;i++){ cin>>x; for(int y:G[x]) vis[y]=true; } ans=0;dfs(1); cout<<n-ans<<'\n'; return 0; }
- 1
信息
- ID
- 796
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 7
- 标签
- 递交数
- 25
- 已通过
- 9
- 上传者