Cod sursa(job #190225)

Utilizator radu_voroneanuVoroneanu Radu Stefan radu_voroneanu Data 21 mai 2008 08:01:18
Problema Triplete Scor 100
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.75 kb
type lat=record  
     x,y:integer;   
     end;   
  
var a:array[1..4096,0..128] of longint;   
    b:array[1..65536] of lat;   
    f,g:text;   
    n,m,i,j,x,y,nr:longint;   
  
begin  
 assign(f,'triplete.in'); reset(f);   
 assign(g,'triplete.out'); rewrite(g);   
 read(f,n,m);   a[1,0]:=0;   
 for i:=1 to m do begin  
  read(f,x,y);   
  a[x,y shr 5]:=a[x,y shr 5] or (1 shl (y and 31));   
  a[y,x shr 5]:=a[y,x shr 5] or (1 shl (x and 31));   
  b[i].x:=x; b[i].y:=y;   
 end;   
 nr:=0;   
 for i:=1 to m do  
  for j:=0 to n shr 5 do begin  
   x:=a[b[i].x,j] and a[b[i].y,j];   
   while x<>0 do begin  
    nr:=nr+(x and 1);   
    x:=x shr 1;   
   end;   
  end;   
 writeln(g,nr div 3);   
 close(f); close(g);   
end.