Pagini recente » Cod sursa (job #1234750) | Cod sursa (job #1971457) | Cod sursa (job #491533) | Cod sursa (job #278262) | Cod sursa (job #1178930)
program p1;
type cutie=record
x,y,z:longint;
end;
var a:array[0..3500] of cutie;
v:array[0..3500] of longint;
f,g:text;
b1,b2:array[0..1 shl 17] of char;
i,n,j,k,u,m,t,ic,sf,poz,max:longint;
function compara(o1,o2:cutie):longint;
begin
if o1.x<o2.x then exit (-1);
if o1.x>o2.x then exit (1);
if o1.y<o2.y then exit (-1);
if o1.y>o2.y then exit (1);
if o1.z<o2.z then exit (-1);
if o1.z>o2.z then exit (1);
exit (0);
end;
procedure quick(left,right:longint);
var i,j:longint;
x,y:cutie;
begin
i:=left;
j:=right;
x:=a[(left+right) div 2];
repeat
while compara(a[i],x)<0 do inc(i);
while compara(a[j],x)>0 do dec(J);
if i<=j then begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(I);
dec(J);
end;
until i>j;
if left<j then quick(left,j);
if i<right then quick(i,right);
end;
begin
assign(f,'cutii.in');reset(F);
assign(g,'cutii.out');rewrite(G);
settextbuf(F,b1);
settextbuf(g,b2);
readln(f,n,t);
for u:=1 to t do begin
for i:=1 to n do begin
readln(f,a[i].x,a[i].y,a[i].z);
v[i]:=0;
end;
quick(1,n);
{ for i:=1 to n do writeln(g,a[i].x,' ',a[i].y,' ',a[i].z); }
k:=0;
v[1]:=1;
for i:=2 to n do
begin
max:=0;
for j:=1 to i-1 do
if (a[i].x>a[j].x) and (a[i].y>a[j].y) and (a[i].z>a[j].z) then
if v[j]>max then max:=v[j];
v[i]:=max+1;
if v[i]>k then k:=v[i];
end;
writeln(g,k);
end;
close(F);
close(G);
end.