Cod sursa(job #12118)

Utilizator bigsarpeadrian bigsarpe Data 2 februarie 2007 22:10:21
Problema Triplete Scor 90
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.71 kb
const maxn=4096;maxbuc=maxn div 16;
var t:Text;
   Pre:Array[0..1 shl 16]of longint;
   X,Y:array[0..1 shl 16]of longint;
   V:Array[0..maxn,0..maxbuc]of word;
   sol,i,j,n,m:longint;
begin
   for i:=0 to 1 shl 16 do for j:=0 to 15 do inc(pre[i],(i shr j)and 1);
   assign(t,'triplete.in');reset(T);readln(t,n,m);
   for i:=1 to M do
   begin
      readln(t,X[i],Y[i]);dec(X[i]);dec(y[i]);
      V[X[i],Y[i]shr 4]:=V[X[i],Y[i]shr 4]or(1 shl (Y[i]and 15));
      V[Y[i],X[i]shr 4]:=V[Y[i],X[i]shr 4]or(1 shl (X[i]and 15));
   end;
   close(T);
   for j:=1 to M do for i:=0 to maxbuc do
      inc(sol,Pre[V[X[j],i]and V[Y[j],i]]);
   assign(T,'triplete.out');rewrite(T);writeln(T,sol div 3);close(T);
end.