记录编号 82848 评测结果 AAAAAAAA
题目名称 [石门中学 2009]切割树 最终得分 100
用户昵称 Gravatar正确率超低的渣渣 是否通过 通过
代码语言 Pascal 运行时间 0.004 s
提交时间 2013-11-27 19:49:52 内存使用 1.65 MiB
显示代码纯文本
var
n,i,j,t,m,x,wait,fu,shang,ys,bh,y,z,ans,da,next,xh,half:longint;
a,dp:array[0..20000]of longint;
b,fft:array[0..20000]of boolean;
ljb:array[0..200000,1..2] of longint;
     function max (x,y:longint):longint;
     begin
         if x>y then  max:=x
                         else  max:=y;
     end;
    procedure try(x:longint);
    var
    j,s,big:longint;
    begin
    b[x]:=true;
    j:=a[x];
    s:=0;
    big:=0;
    while j<>0 do begin
                if b[ljb[j,1]]=false    then begin

                                            try(ljb[j,1]);
                                            s:=s+dp[ljb[j,1]];
                                            big:=max(big,dp[ljb[j,1]]);
                                            end;
                j:=ljb[j,2];
                end;

                        dp[x]:=s+1;
                        big:=max(big,n-s-1);
                        if big <=half then fft[x]:=true;

  end;


begin
assign(input,'treecut.in');
reset(input);
assign(output,'treecut.out');
rewrite(output);
  readln(n);
  xh:=0;
  for i:=1 to n-1 do
  begin
  readln(x,y);

  xh:=xh+1;
  ljb[xh,1]:=y;
  ljb[xh,2]:=a[x];
  a[x]:=xh;

  xh:=xh+1;
  ljb[xh,1]:=x;
  ljb[xh,2]:=a[y];
  a[y]:=xh;
  end;
 half:=n div 2;
 if n mod 2 =1 then half:=half+1;



  try(1);


for i:=1 to n do
if fft[i]=true then writeln(i);



close(input);
close(output);
end.