Pagini recente » Cod sursa (job #2190864) | Cod sursa (job #374233) | Cod sursa (job #81225) | Cod sursa (job #2819780) | Cod sursa (job #40967)
Cod sursa(job #40967)
const maxn = 1001;
var f:text;
n,m,i,nr1,nr2,cnt1,cnt2,t,k,max:longint;
a,b,c,x,y,s1,s2,f1,f2,a1,a2,x1,y1:array[1..maxn]of integer;
procedure readdata;
begin
max:=1;
assign(f,'regiuni.in');
reset(f);
readln(f,n,m);
for i:=1 to n do
begin
readln(f,a[i],b[i],c[i]);
end;
for i:=1 to m do
begin
readln(f,x[i],y[i]);
end;
close(f);
end;
procedure copy;
begin
if (nr1>0) and (nr2>0) then inc(max);
if (nr1>1) then
begin
inc(cnt2);
s2[cnt2]:=s1[t];
f2[cnt2]:=s1[t]+nr1-1;
for i:=1 to nr1 do
begin
x[s2[cnt2]+i-1]:=x1[a1[i]];
y[s2[cnt2]+i-1]:=y1[a1[i]];
end;
end;
if (nr2>1) then
begin
inc(cnt2);
s2[cnt2]:=s1[t]+nr1;
f2[cnt2]:=f1[t];
for i:=1 to nr2 do
begin
x[s2[cnt2]+i-1]:=x1[a2[i]];
y[s2[cnt2]+i-1]:=y1[a2[i]];
end;
end;
end;
procedure determina;
begin
for i:=s1[t] to f1[t] do
begin
if (a[k]*x[i]+b[k]*y[i]+c[k]>0) then
begin
inc(nr1);
a1[nr1]:=i;
end
else
begin
inc(nr2);
a2[nr2]:=i;
end;
end;
end;
procedure solve;
begin
cnt1:=1;
s1[1]:=1;
f1[1]:=m;
for k:=1 to n do
begin
cnt2:=0;
x1:=x;
y1:=y;
for t:=1 to cnt1 do
begin
nr1:=0;
nr2:=0;
determina;
copy;
end;
cnt1:=cnt2;
s1:=s2;
f1:=f2;
end;
end;
procedure writedata;
begin
assign(f,'regiuni.out');
rewrite(f);
writeln(f,max);
close(f);
end;
begin
readdata;
solve;
writedata;
end.