Cod sursa(job #88926)

Utilizator johnyJohny Deep johny Data 4 octombrie 2007 20:38:20
Problema Triplete Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.59 kb
program triplete;
var x,y: array[1..65536] of integer;
    A:array[1..4096,1..4096] of byte;
    m,n,i,j,rez: longint;

function suma(x,y:integer):longint;
var j: integer;
    r: longint;
begin
  r:=0;
  for j:=1 to n do
    if A[x,j]*A[y,j]=1 then r:=r+1;
  suma:=r;
end;

begin
  assign(input,'triplete.in');
  reset(input);
  readln(n,m);
  for i:=1 to m do
  begin
    readln(x[i],y[i]);
    A[x[i],y[i]]:=1;
  end;
  for i:=1 to m do
    rez:=rez+suma(x[i],y[i]);

  assign(output,'triplete.out');
  rewrite(output);
  write(rez);
  close(input);
  close(output);
end.