Cod sursa(job #40281)

Utilizator andrei_infoMirestean Andrei andrei_info Data 27 martie 2007 12:28:54
Problema Regiuni Scor 60
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.71 kb
const nmax= 1000;
     bmax= 34;
type dr = record
        a,b,c:integer;
        end;
     pc = record
        x,y:integer;
        end;
var lpc:array[1..nmax] of pc;
    ldr:array[1..nmax] of dr;
    a:array[1..nmax,1..40] of longint ; //false sub, true peste
    n,m:longint;

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,(j div 30)]:=false
                      inc(a[i,(j div 30) + 1],1 shl ( j mod 30) );
                end;
end;

function ok (l1,l2:integer):boolean;
var i:integer;
begin
ok:=true;
for i:=1 to bmax do
        if a[l1,i] <> a[l2,i] then
                begin
                ok:=false;
                exit;
                end;
end;

procedure afla;
var rez:longint;
    i,j:integer;
    viz:array[1..nmax] of boolean;
begin
fillchar(viz,sizeof(viz),false);
rez:=0;
for i:=1 to m do
        if not viz[i] then
                begin
                inc(rez);
                viz[i]:=true;
                for j:=1 to m do
                        if ok(i,j) then
                                viz[j]:=true;
                end;

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

begin
writeln((sizeoF(lpc)+sizeof(ldr) + sizeof(a))/1024:5:2);
citire;
calc;
afla;

end.