Pagini recente » Cod sursa (job #2183050) | Cod sursa (job #900302) | Cod sursa (job #1844949) | Cod sursa (job #394773) | Cod sursa (job #170628)
Cod sursa(job #170628)
type cutie=record
x,y,z:1..3500;
end;
tablou=array[1..3500] of cutie;
var f,g:text; t:1..100;i,j,k:1..3500;n:1..3500;aux,w:cutie;xx:cutie;a:tablou; l:array[1..3500] of integer; ok:boolean;
max,min:integer;
procedure sortare(l,r:byte);
var i,j,x,y:byte;
begin
i:=l; j:=r; xx:=a[(l+r) div 2];
repeat
while a[i].x<xx.x do i:=i+1;
while xx.x<a[j].x do j:=j-1;
if i<=j then begin w:=a[i]; a[i]:=a[j]; a[j]:=w; i:=i+1; j:=j-1;
end
until i>j;
if l<j then sortare(l,j);
if r>i then sortare(i,r);
end;
begin
assign(f,'cutii.in');
assign(g,'cutii.out');
reset(f); rewrite(g);
readln(f,n,t);
for i:=1 to t do begin
for j:=1 to n do readln(f, a[j].x, a[j].y, a[j].z);
sortare(1,n);
l[n]:=1;
for k:=n-1 downto 1 do
begin
l[k]:=1;
for j:=1+k to n do
if (a[k].x< a[j].x) and (a[k].y<a[j].y) and (a[k].z<a[j].z) and (l[k]<1+l[j]) then
l[k]:=1+l[j];
end;
max:=l[1];
for k:=2 to n do
if max<l[k] then max:=l[k];
writeln(g, max); end;
close(f);
close(g);
end.