i, j, k, n, p, x, y, min, s, s0: longint;
temp, t: longint;
b: array[0..500] of longint;
a: array[0..400,0..400] of longint;
procedure work(i: longint);
var
ii, j, k, t, s0: longint;
flag: boolean;
root1, root2: integer;
begin
if a[i,0]<=1 then begin
if s<min then min := s;
exit;
end;
s0 := s;
flag := true;
for j := 1 to a[i,0] do if a[a[i,j],0]>0 then begin
flag := false;
s := s0+a[i,0]-1;
if j=1 then root1 := 2 else root1 := 1;
root2 := a[i,root1];
t := a[root2,0];
for k := 1 to t do b[k] := a[root2,k];
for k := 1 to t do if (k<>root1) and (k<>j) then begin
for ii := 1 to a[a[i,k],0] do
a[root2,a[root2,0]+ii] := a[a[i,k],ii];
a[root2,0] := a[root2,0]+a[a[i,k],0];
end;
work(root2);
a[root2,0] := t;
for ii := 1 to t do a[root2,ii] := b[ii];
end;
if flag then begin
s := s0+a[i,0]-1;
if s<min then min := s;
exit;
end;
end;
begin
assign(input,'d:\01.txt');
reset(input);
assign(output,'d:\01out.txt');
rewrite(output);
readln(n,p);
for i := 1 to n do a[i,0] := 0;
for i := 1 to p do begin
readln(x,y);
if x>y then begin
t := x;
x := y;
y := t;
end;
inc(a[x,0]);
a[x,a[x,0]] := y;
end;
s := 1;
min := maxlongint;
work(1);
writeln(min);
close(input);
close(output);
end.
用搜索做的 可是一直都是50分 谁能告诉我为什么啊啊啊啊