Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求解释哪错了,在此先谢过了

Posted by shiyan01 at 2011-09-17 16:57:58 on Problem 1469
type
 edge=record
  y,next:longint;
 end;
var
 first,c:array[0..400]of longint;
 b:array[0..400]of boolean;
 a:array[0..2000]of edge;
 n,tot,m,p:longint;
//================================================
procedure ad_edge(x,y:longint);
begin
 inc(tot);
 a[tot].y:=y;
 a[tot].next:=first[x];
 first[x]:=tot;
end;
//================================================
procedure init;
var
 i,j,k,x:longint;
begin
 readln(n,m);
 for i:=1 to n do
  begin
   read(k);
   for j:=1 to k do
    begin
     read(x);
     ad_edge(i,x);
    end;
   readln;
  end;
end;
//============================================
function path(x:longint):boolean;
var
 t,i,j:longint;
begin
 t:=first[x];
 while t>0 do
  begin
   if not b[a[t].y] then
    begin
     b[a[t].y]:=true;
     if (c[a[t].y]=0)or(path(a[t].y)) then
      begin
       c[a[t].y]:=x;
       exit(true);
      end;
    end;
   t:=a[t].next;
  end;
 exit(false);
end;
//=============================================
procedure xiongyali;
var
 i,ans:longint;
begin
 ans:=0;
 for i:=1 to n do
  begin
   fillchar(b,sizeof(b),false);
   if path(i) then inc(ans);
  end;
 if ans<>n then writeln('NO') else writeln('YES');
end;
//==============================================
begin
 readln(p);
 while p>0 do
  begin
   fillchar(first,sizeof(first),0);
   fillchar(b,sizeof(b),false);
   fillchar(c,sizeof(c),0);
   tot:=0;
   init;
   dec(p);
   xiongyali;
  end;
end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator