Pagini recente » Cod sursa (job #788313) | Cod sursa (job #2885373) | Cod sursa (job #1047990) | Cod sursa (job #1103119) | Cod sursa (job #1178872)
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:longint;
function cauta(x:longint) : longint;
var mijl:longint;
begin
ic:=1;
sf:=k;
while ic<=sf do begin
mijl:=(ic+sf) div 2;
if x<v[mijl] then sf:=mijl-1
else ic:=mijl+1;
end;
cauta:=ic;
end;
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;
for i:=1 to n do begin
poz:=cauta(a[i].z);
v[poz]:=a[i].z;
if poz>k then k:=poz;
end;
writeln(g,k);
end;
close(F);
close(G);
end.