一道搜索题,对于被割断的点最少的情况下,一定是损坏的牛棚刚刚好可以把那些发了短信的点包围导致其无法连通至1,然后根据这样子的情况来求出一个最优的切割情况,然后直接DFS出最优切割情况下仍然连通的点数,然后用N减一下完事。。
1 type
2 point=^node;
3 node=record
4 g:longint;
5 next:point;
6 end;
7 var
8 i,j,k,l,m,n,t,ans:longint;
9 a:array[0..100000] of point;
10 b,c,d:array[0..100000] of longint;
11 p:point;
12 procedure add(x,y:longint);inline;
13 var p:point;
14 begin
15 new(p);p^.g:=y;p^.next:=a[x];a[x]:=p;
16 end;
17 procedure dfs(x:longint);inline;
18 var p:point;
19 begin
20 if b[x]<>0 then exit;
21 inc(ans);b[x]:=1;
22 p:=a[x];
23 while p<>nil do
24 begin
25 if b[p^.g]=0 then dfs(p^.g);
26 p:=p^.next;
27 end;
28 end;
29 begin
30 readln(n,m,t);
31 for i:=1 to n do a[i]:=nil;
32 for i:=1 to m do
33 begin
34 readln(j,k);
35 add(j,k);add(k,j);
36 end;
37 fillchar(b,sizeof(b),0);
38 for i:=1 to t do
39 begin
40 readln(j);
41 b[j]:=1;
42 p:=a[j];
43 while p<>nil do
44 begin
45 if b[p^.g]=0 then b[p^.g]:=-1;
46 p:=p^.next;
47 end;
48 end;
49 for i:=1 to n do if b[i]=1 then b[i]:=-1;
50 ans:=0;
51 dfs(1);
52 writeln(n-ans);
53 end.