Pagini recente » Cod sursa (job #705358) | Cod sursa (job #1115171) | Cod sursa (job #2779419) | Cod sursa (job #1930527) | Cod sursa (job #604181)
Cod sursa(job #604181)
Program cutii;
type dimens=record
x,y,z:integer;
end;
var n,t,i,j,max,p,m,s,q,posmax:integer;
a: array [1..3500] of dimens;
b: array [1..3500] of integer;
b1,b2:array [1..1 shl 12] of char;
fi, fo:text;
begin
assign(fi,'cutii.in');
assign(fo,'cutii.out');
settextbuf(fi,b1);
settextbuf(fo,b2);
reset(fi);
rewrite(fo);
readln(fi,n,t);
for m:=1 to t do begin
q:=0;
for i:=1 to n do begin
read(fi,s); a[s].x:=s;
if s>q then q:=s;
readln(fi,a[s].y,a[s].z);
end;
b[q]:=1; max:=0; posmax:=q;
for i:=q-1 downto 1 do begin
p:=i;
for j:=i+1 to posmax do
if (a[j].y>a[i].y) and (a[j].z>a[i].z) and (b[j]>b[p]) then p:=j;
b[i]:=b[p]+1;
if b[i]>max then begin
max:=b[i];
posmax:=i;
end;
end;
writeln(fo,max);
for i:=1 to q-1 do b[i]:=0;
end;
close(fo);
end.