| ||||||||||
| 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 | |||||||||
为什么我自己用waterloo的数据测是对的,交上来是runtime errorvar
n,i,j,ans,num,f,t,v:longint;
m,d,father,dui:array [1..10000] of longint;
procedure main;
begin
while t<f do
begin
t:=t+1;
m[father[dui[t]]]:=m[father[dui[t]]]+m[dui[t]]-1;
d[father[dui[t]]]:=d[father[dui[t]]]-1;
if d[father[dui[t]]]=0 then
begin
f:=f+1;
dui[f]:=father[dui[t]];
d[dui[f]]:=maxlongint;
end;
ans:=ans+abs(m[dui[t]]-1);
end;
end;
begin
readln(n);
while n<>0 do
begin
f:=0;t:=0;
for i:=1 to n do
begin
read(num);
read(m[num],d[num]);
if d[num]=0 then
begin
f:=f+1;
dui[f]:=num;
d[num]:=maxlongint;
end
else
for j:=1 to d[num] do
begin
read(v);
father[v]:=i;
end;
readln;
end;
ans:=0;
main;
writeln(ans);
readln(n);
end;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator