Cod sursa(job #38150)

Utilizator andrei_infoMirestean Andrei andrei_info Data 25 martie 2007 15:10:53
Problema Regiuni Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.52 kb
const nmax= 1000;
type dr = record
        a,b,c:longint;
        end;
     pc = record
        x,y:longint;
        end;
var lpc:array[1..nmax] of pc;
    ldr:array[1..nmax] of dr;
    a:array[1..nmax] of string; //false sub, true peste
    n,m:integer;

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

procedure calc;
var i,j:integer;
    aux:longint;
begin

for i:=1 to m do
        for j:=1 to n do
                begin
                aux:=lpc[i].x * ldr[j].a  + lpc[i].y * ldr[j].b;
                if aux < -ldr[j].c then
                        a[i]:=a[i]+'0'
                else    a[i]:=a[i]+'1';
        end;
end;


procedure Sort(l, r: Integer);
var
  i, j: integer;
  x, y:ansistring;
begin
  i := l; j := r; x := a[(l+r) DIV 2];
  repeat
    while a[i] < x do i := i + 1;
    while x < a[j] do j := j - 1;
    if i <= j then
    begin
      y := a[i]; a[i] := a[j]; a[j] := y;
      i := i + 1; j := j - 1;
    end;
  until i > j;
  if l < j then Sort(l, j);
  if i < r then Sort(i, r);
end;

procedure afla;
var rez:longint;
    i,j:integer;
    k:boolean;
begin
rez:=1;
for i:=2 to m do
        if a[i] <> a[i-1] then
                inc(rez);

assign(output,'regiuni.out'); rewritE(output);
writeln(rez);
close(output);
end;

begin
citire;
calc;
sort(1,m);
afla;

end.