Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我也可耻地一遍0msAC了In Reply To:我可耻的一遍0msAC了 Posted by:hzl001 at 2011-06-06 17:19:37 LZ怎么写的这么长啊。。我的多好看! const b:array[false..true]of string= (' not',''); var s:set of 0..100; flag,null:boolean; count,i,x,y:longint; rd,f:array[0..100]of longint; function find(x:longint):longint; begin if f[x]=x then exit(x); find:=find(f[x]); f[x]:=find; end; begin count:=0; while true do begin s:=[]; flag:=true; null:=false; fillchar(rd,sizeof(rd),0); for i:=1 to 100 do f[i]:=i; while true do begin read(x,y); if x+y=0 then break; if x+y<0 then halt; if x=y then flag:=false; if find(x)=find(y) then flag:=false; f[find(x)]:=find(y); inc(rd[y]); s:=s+[x]+[y]; end; for i:=1 to 100 do if i in s then begin if rd[i]=0 then begin if null then begin flag:=false; break; end else null:=true; end else begin if rd[i]<>1 then begin flag:=false; break; end; end; end; if s=[] then begin flag:=true; null:=true; end; inc(count); writeln('Case ',count,' is',b[flag and null],' a tree.'); end; end. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator