Cod sursa(job #47374)

Utilizator florin_marius90Florin Marius Popescu florin_marius90 Data 3 aprilie 2007 17:14:02
Problema Pachete Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.29 kb
type punct=record
           x,y:0..2000000000;
           end;
     vector2=array[1..60000] of boolean;
     vector=array[0..60000] of punct;

var v:vector; f,g:text;
    a:vector2;
    k,n,nr,i,j:longint;

procedure poz(li,ls:longint;var k:longint;var v:vector);
var j,i,c,i1,j1:longint;
begin
i1:=0; j1:=-1;
i:=li; j:=ls;
while i<j do
 begin
   if v[i].x>v[j].x
          then
            begin
            c:=v[j].x;
            v[j].x:=v[i].x;
            v[i].x:=c;
            c:=i1;
            i1:=-j1;
            j1:=c;
            end;
 i:=i+i1;
 j:=j+j1;
 end;
k:=i;
end;

procedure quick(li,ls:longint);
begin
if li<ls
     then
      begin
       poz(li,ls,k,v);
       quick(li,k-1);
       quick(k+1,ls);
      end;
end;





begin
assign(f,'pachete.in'); assign(g,'pachete.out');
reset(f); rewrite(g);

readln(f,n);
readln(f,v[0].x,v[0].y);
for i:=1 to n do
 begin
 readln(f,v[i].x,v[i].y);
 a[i]:=true;
 end;

quick(1,n);
nr:=0;

for i:=1 to n do
 if a[i] then
 begin

  inc(nr);
  a[i]:=false;
  for j:=i+1 to n do
   begin
   if a[j] then
   if (v[j].x-v[0].x)*(v[i].y-v[0].y)=(v[i].x-v[0].x)*(v[j].y-v[0].y)
               then
                a[j]:=false;

   end;

 end;

write(g,nr);
close(f); close(g);
end.