Cod sursa(job #287229)

Utilizator DelmuI.D. Margarit Delmu Data 24 martie 2009 17:20:14
Problema Triplete Scor 0
Compilator fpc Status done
Runda aa Marime 0.43 kb
var a:array[1..4097,1..4097] of boolean;
    n,i,j,k,s:integer;
    m:longint;
    f,t:text;
begin
assign(f,'triplete.in');assign(t,'triplete.out');
reset(f);
read(f,n);readln(f,m);
s:=0;
while not eof(f) do
begin
 read(f,i); readln(f,j);
 a[i,j]:=true;
end;
close(f);
for i:=1 to n do
 for j:=1 to n do if a[i,j] then
   for k :=1 to n do if a[i,k] and a[k,j] then inc(s);
rewrite(t);
writeln(t,s);
close(t);

end.