Pagini recente » Cod sursa (job #2255333) | Cod sursa (job #764006) | Cod sursa (job #1251883) | Cod sursa (job #780831) | Cod sursa (job #35074)
Cod sursa(job #35074)
type cutie=record
x,y,z:longint;
end;
var v:array[1..3502]of cutie;
x,zero:array[1..3502]of integer;
t,i,j,k,n,max:longint;
aux:cutie;
procedure qSort(l, r: Integer);
var
i, j, x: integer;
y:cutie;
begin
i := l; j := r; x := v[(l+r) DIV 2].z;
repeat
while v[i].z < x do i := i + 1;
while x < v[j].z do j := j - 1;
if i <= j then
begin
y := v[i]; v[i] := v[j]; v[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
readln(v[i].x,v[i].y,v[i].z);
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[i].x<v[j].x)and(v[i].y<v[j].y)then
begin
if x[i]<x[j]+1
then x[i]:=x[j]+1;
{ if x[i]>max then
begin
max:=x[i];
break;
end;}
end;
end;
max:=1;
for i:=1 to n do
if x[i]>max then
max:=x[i];
writeln(max);
end;
close(input);close(output);
end.