Cod sursa(job #36355)

Utilizator cheery_g1rlHaller Emanuela cheery_g1rl Data 23 martie 2007 14:06:50
Problema Triplete Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.65 kb
type inte=0..65536;
var f,g:text;
    a:array[1..4096,1..4096] of 0..1;
    m,i,c:inte;
    n,j,k,x,y:integer;
begin
assign(f,'triplete.in');
reset(f);
readln(f,n,m);
fillchar(a,sizeof(a),0);
for i:=1 to m do
  begin
    readln(f,x,y);
    a[x,y]:=1;
    a[y,x]:=1;
  end;
close(f);
c:=0;
for i:=1 to n do
   begin
  for j:=1 to n do
     begin
      if (a[i,j]=1)and(a[j,i]=1) then
         begin
           a[j,i]:=0;
           for k:=1 to n do
           if (a[j,k]=1)and(a[i,k]=1) then
                 begin a[k,i]:=0; inc(c); end;
         end; end; end;
assign(g,'triplete.out');
rewrite(g);
writeln(g,c);
close(g);
end.