Pagini recente » Cod sursa (job #1829495) | Cod sursa (job #1955531) | Cod sursa (job #2861924) | Cod sursa (job #1807705) | Cod sursa (job #37754)
Cod sursa(job #37754)
const fi='regiuni.in';
fo='regiuni.out';
max=1000;
type coloana=array[1..max] of boolean;
var t:text;
n,m,i,j,k,numar:integer;
dr:array[1..3,1..max] of integer;
pct:array[1..2, 1..max] of integer;
matrice:array[1..max] of coloana; {dr, pct true if >0 elese false}
vazut:coloana;
procedure init;
begin
assign(t, fi);
reset(t);
readln(t,n,m);
for i:=1 to n do
readln(t, dr[1,i], dr[2,i], dr[3,i]);
for i:=1 to m do readln(t, pct[1,i], pct[2,i]);
close(t);
end;
function semn(i,j:integer):boolean;
begin
semn:=false;
if dr[1, i]*pct[1, j]+dr[2,i]*pct[2,j]+dr[3,i]>0 then semn:=true;
end;
procedure creare_matrice;
var i,j:integer;
begin
for i:=1 to n do
for j:=1 to m do
matrice[i][j]:=semn(i,j);
end;
function comparare(a,b:integer ):boolean;
var i:integer;
begin
comparare:=true;
for i:=1 to n do
if matrice[i][a]<>matrice[i][b] then comparare:=false;
end;
begin
init;
creare_matrice;
for i:=1 to m do vazut[i]:=false;
numar:=0;
for i:=1 to m do
begin
j:=i+1;
if vazut[i]<>true then numar:=numar+1;
for k:=j to m do vazut[k]:=comparare(i,k);
end;
assign(t, fo);
rewrite(t);
writeln(t,numar);
close(t);
end.