Pagini recente » Cod sursa (job #468806) | Cod sursa (job #297279) | Cod sursa (job #3293861) | Cod sursa (job #3031522) | Cod sursa (job #58422)
Cod sursa(job #58422)
program cutii;
const
fin='cutii.in';
fout='cutii.out';
nmax=3500;
type
box=record
x,y,z:longint;
end;
var
a:array[1..nmax] of box;
nr:array[0..nmax] of longint;
st,dr,mid,i,j,k,n,it,t,x,y,z,max,best:longint;
procedure scufunda(i,n:integer);
var
p:integer;
aux:box;
begin
p:=i;
if i shl 1<=n then
if (a[i shl 1].x<a[i].x)or((a[i shl 1].x=a[i].x)and(a[i shl 1].y<a[i shl 1].y)) then
p:=i shl 1
else if ((a[i shl 1].x=a[i].x)and(a[i shl 1].y=a[i].y))and(a[i shl 1].z<a[i].z) then
p:=i shl 1;
if i shl 1 or 1<=n then
if (a[i shl 1 or 1].x<a[p].x)or((a[i shl 1 or 1].x=a[p].x)and(a[i shl 1 or 1].y<a[p].y)) then
p:=i shl 1 or 1
else if ((a[i shl 1 or 1].x=a[p].x)and(a[i shl 1 or 1].y=a[p].y))and(a[i shl 1 or 1].z<a[p].z) then
p:=i shl 1 or 1;
if p<>i then
begin
aux:=a[i];a[i]:=a[p];a[p]:=aux;
scufunda(p,n);
end;
end;
function ok(i,j:integer):boolean;
begin
ok:=((a[i].x<a[j].x)and(a[i].y<a[j].y))and(a[i].z<a[j].z);
end;
procedure hsort(n:integer);
var
i:integer;
aux:box;
begin
for i:=n shr 1 downto 1 do
scufunda(i,n);
for i:=n downto 2 do
begin
aux:=a[1];a[1]:=a[i];a[i]:=aux;
scufunda(1,i-1);
end;
end;
begin
assign(input,fin);
assign(output,fout);
reset(input);
rewrite(output);
readln(n,t);
for it:=1 to t do
begin
best:=0;
a[n+1].x:=nmax+1;a[n+1].y:=nmax+1;a[n+1].z:=nmax+1;
for i:=1 to n do
readln(a[i].x,a[i].y,a[i].z);
hsort(n);
fillchar(nr,sizeof(nr),0);
nr[0]:=n+1;
max:=0;
for i:=1 to n do
begin
st:=0;dr:=max;
best:=0;
while (st<=dr) do
begin
mid:=(st+dr) shr 1;
if ok(i,nr[mid]) then
begin
if mid>best then
best:=mid;
st:=mid+1;
end
else
dr:=mid-1;
end;
if best=max then
begin
inc(max);
nr[max]:=i;
end;
end;
writeln(max);
end;
close(input);
close(output);
end.