Pagini recente » Cod sursa (job #376897) | Cod sursa (job #1234173) | Cod sursa (job #509185) | Cod sursa (job #2925798) | Cod sursa (job #35102)
Cod sursa(job #35102)
const zero=ord('0');
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;
s:string[20];
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]].x < v[x].x do i := i + 1;
while v[x].x < v[ind[j]].x 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(s);
j:=1;
v[i].x:=0;
s:=s+' ';
while (s[j]<>' ') do begin v[i].x:=v[i].x*10+ord(s[j])-zero;inc(j);end;
inc(j);
v[i].y:=0;
while (s[j]<>' ') do begin v[i].y:=v[i].z*10+ord(s[j])-zero;inc(j);end;
inc(j);
v[i].z:=0;
while (s[j]<>' ') do begin v[i].z:=v[i].z*10+ord(s[j])-zero;inc(j);end;
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]].y<v[ind[j]].y)and(v[ind[i]].z<v[ind[j]].z)and(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;
writeln(max);
end;
close(input);close(output);
end.