#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<stack>
#define N 10005
#define ll long long
using namespace std;
vector<int>e[1005];
int vis[1005];
int x;
void dfs(int u)
{
if(vis[u]||u == x)return;
vis[u] = 1;
for(int i = 0;i<e[u].size();i++)dfs(e[u][i]);
}
int main()
{
int n,m,k,i,j,a,b,num;
while(scanf("%d%d%d",&n,&m,&k)!=EOF)
{
for(i = 1;i<=m;i++)
{
scanf("%d%d",&a,&b);
e[a].push_back(b);
e[b].push_back(a);
}
for(i = 1;i<=k;i++)
{
scanf("%d",&x);
num = 0;
memset(vis,0,sizeof(vis));
for(j = 1;j<=n;j++)
{
if(!vis[j]&&j!=x)
{
dfs(j);
num++;
}
}
printf("%d\n",num-1);
}
}
return 0;
}
pat1013 Battle Over Cities
最新推荐文章于 2015-03-13 11:34:01 发布