Cod sursa(job #39251)

Utilizator andrei_blanaruAndrei Blanaru andrei_blanaru Data 26 martie 2007 16:06:31
Problema Regiuni Scor 100
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.41 kb
type punct=record
            x,y:integer;
          end;
     dreapta=record
               a,b,c:integer;
             end;

var n,m,count:integer;
    dr:array [1..1000] of dreapta;
    pu:array [1..1000] of punct;
    tip,sus,jos,unde:array [0..1000] of integer;


procedure citire;
var i:integer;
begin
  assign(input,'regiuni.in');
  reset(input);
  readln(n,m);
  for i:=1 to n do
    readln(dr[i].a,dr[i].b,dr[i].c);
  for i:=1 to m do
    readln(pu[i].x,pu[i].y);
  close(input);
end;

function ecuatie(i,j:integer):longint;
begin
  ecuatie:=dr[i].a*pu[j].x+dr[i].b*pu[j].y+dr[i].c;
end;

procedure prel;
var i,j:integer;
begin
  for i:=1 to n do
    begin
      fillchar(sus,sizeof(sus),0);
      fillchar(jos,sizeof(jos),0);
      fillchar(unde,sizeof(unde),0);
      for j:=1 to m do
        if ecuatie(i,j)>0
          then  begin
                  inc(sus[tip[j]]);
                  unde[j]:=1;
                end
          else  begin
                  inc(jos[tip[j]]);
                  unde[j]:=-1;
                end;
      for j:=1 to m do
        if unde[j]=-1
          then  inc(tip[j],sus[tip[j]]);
    end;
  fillchar(unde,sizeof(unde),0);
  for i:=1 to m do
    unde[tip[i]]:=1;
  for i:=0 to m do
    count:=count+unde[i];
end;


begin
  citire;
  prel;
  assign(output,'regiuni.out');
  rewrite(output);
  writeln(count);
  close(output);
end.