Cod sursa(job #24400)

Utilizator ScrazyRobert Szasz Scrazy Data 2 martie 2007 11:16:46
Problema Triplete Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.49 kb
var n,m:longint;
    i,j,x,y,db,k:longint;
    a:array[1..40,1..40] of 0..1;
    f:text;
begin
  assign(f,'triplete.in');
  reset(f);
  readln(f,n,m);
  for i:=1 to m do begin
    readln(f,x,y);
    a[x,y]:=1;
    a[y,x]:=1;
  end;
  close(f);
  db:=0;
  for i:=1 to n do
    for j:=i+1 to n do
      if a[i,j]=1 then
        for k:=1 to i do
          if (a[i,k]=1)and(a[j,k]=1) then db:=db+1;

  assign(f,'triplete.out');
  rewrite(f);
  writeln(f,db);
  close(f);

end.