-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1013.cpp
56 lines (49 loc) · 1011 Bytes
/
1013.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
52
53
54
55
56
//
// 1013.cpp
// 算法
//
// Created by 王怡凡 on 2017/5/26.
// Copyright © 2017年 王怡凡. All rights reserved.
//
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
const int N = 1111;
vector<int> G[N];
bool vis[N];
int currentPoint;
void dfs(int v) {
if(v==currentPoint) {
return ;
}
vis[v] = true;
for(int i=0;i<G[v].size();i++) {
if(vis[G[v][i]]==false) {
dfs(G[v][i]);
}
}
}
int n,m,k,i,query;
int main() {
scanf("%d%d%d",&n,&m,&k);
for(i=0;i<m;i++) {
int a,b;
scanf("%d %d",&a,&b);
G[a].push_back(b);
G[b].push_back(a);
}
for(query=0;query<k;query++) {
scanf("%d",¤tPoint);
memset(vis,false,sizeof(vis));
int block = 0;
for(i=1;i<=n;i++) {
if(i!=currentPoint&&vis[i]==false) {
dfs(i);
block++;
}
}
printf("%d\n",block-1);
}
return 0;
}