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

请帮忙看看偶这个pas的程序有啥bug?为什么会wa掉?

Posted by xiaobai at 2004-05-26 21:52:14 on Problem 1330
program p1330;
var f:array[0..11000]of integer;
    b:array[0..11000]of boolean;
    t,i,n,x,y:integer;

procedure init;
  var i,a,b:integer;
begin
  readln(n);
  fillchar(f,sizeof(f),0);
  fillchar(b,sizeof(b),false);
  for i:=1 to n-1 do begin
    readln(a,b);
    f[b]:=a;
  end;
  readln(x,y);
end;

procedure work;
  var c:integer;
begin
  c:=x;b[c]:=true;
  while c<>0 do begin
    b[c]:=true;
    c:=f[c];
  end;
  c:=y;
  while not b[c] do c:=f[c];
  writeln(c);
end;

begin
//  assign(input,'input.txt');reset(input);
//  assign(output,'output.txt');rewrite(output);
  readln(t);
  for i:=1 to t do begin
    init;
    work;
  end;
//  close(input);close(output);
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