Pagini recente » Cod sursa (job #2877512) | Cod sursa (job #319055) | Cod sursa (job #2757427) | Cod sursa (job #2525389) | Cod sursa (job #35088)
Cod sursa(job #35088)
type cutie=record
x,y,z:longint;
end;
var v:array[1..3502]of cutie;
x,ind:array[1..3502]of integer;
t,i,j,k,n,max:longint;
aux:cutie;
procedure qSort(l, r: Integer);
var
i, j, x, y: integer;
begin
i := l; j := r; x := ind[(l+r) DIV 2];
repeat
while v[ind[i]].y < v[x].y do i := i + 1;
while v[x].y < v[ind[j]].y do j := j - 1;
if i <= j then
begin
y := ind[i]; ind[i] := ind[j]; ind[j] := y;
i := i + 1; j := j - 1;
end;
until i > j;
if l < j then qSort(l, j);
if i < r then qSort(i, r);
end;
begin
assign(input,'cutii.in');reset(input);
assign(output,'cutii.out');rewrite(output);
readln(n,t);
for k:=1 to t do
begin
for i:=1 to n do begin
readln(v[i].x,v[i].y,v[i].z);
ind[i]:=i;
end;
qsort(1,n);
x[n]:=1;
max:=1;
for i:=n-1 downto 1 do
begin
x[i]:=1;
for j:=i+1 to n do
if (v[ind[i]].x<v[ind[j]].x)and(v[ind[i]].z<v[ind[j]].z)then
begin
if x[i]<x[j]+1
then begin
x[i]:=x[j]+1;
if x[i]>max then
begin
max:=x[i];
break;
end;
end;
end;
end;
writeln(max);
end;
close(input);close(output);
end.