Post
by **Eduard** » Sun Nov 23, 2003 8:15 am

I get WA when i submit it but it works correct for any test on my computer(also for multigraphs too)

Can someone help me.

This is my code.

[pascal]program acm125;

var a,b,c,s,sum:array[0..30,0..30] of integer;

number,i,j,n,k,u,v,max:integer;

procedure mult;

var i,j,k:integer;

begin

for i:=0 to n do

for j:=0 to n do

c[i,j]:=0;

for i:=0 to n do

for j:=0 to n do

for k:=0 to n do

begin

c[i,j]:=c[i,j]+b[i,k]*a[k,j];

end;

for i:=0 to n do

for j:=0 to n do

begin

s[i,j]:=s[i,j]+c[i,j];

b[i,j]:=c[i,j];

c[i,j]:=0;

end;

end;

begin

number:=-1;

while not eof do

begin

number:=number+1;

read(n);

for i:=0 to n do

for j:=0 to n do

a[i,j]:=0;

v:=0;

max:=0;

for i:=1 to n do

begin

read(u,v);

if max<u then max:=u;

if max<v then max:=v;

a[u,v]:=a[u,v]+1;

end;

n:=max;

for i:=0 to n do

for j:=0 to n do

begin

b[i,j]:=a[i,j];

s[i,j]:=a[i,j];

end;

for i:=1 to n do

mult;

for i:=0 to n do

for j:=0 to n do

sum[i,j]:=s[i,j];

for i:=1 to n+1 do

mult;

for i:=0 to n do

for j:=0 to n do

if sum[i,j]<>s[i,j] then sum[i,j]:=-1;

writeln('matrix for city ',number);

for i:=0 to n do

begin

for j:=0 to n do

write(sum[i,j],' ');

writeln;

end;

end;

end.[/pascal]