| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
好像做过的var
a,b,f:array[1..5000] of longint;
l,r,i,t,te,n,len:longint;
procedure swap(var x,y:longint);
begin if x<>y then begin x:=x xor y;y:=y xor x;x:=x xor y; end; end;
procedure qsort(l,r:longint);
var
i,j,x,y:longint;
begin
i:=l;j:=r;x:=b[(l+r) shr 1];y:=a[(l+r) shr 1];
while i<=j do
begin
while (b[i]<x) or ((b[i]=x) and (a[i]<y)) do inc(i);
while (b[j]>x) or ((b[j]=x) and (a[j]>y)) do dec(j);
if i<=j then
begin
swap(a[i],a[j]);swap(b[i],b[j]);
inc(i);dec(j);
end;
end;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
readln(te);
for t:=1 to te do
begin
readln(n);
for i:=1 to n do read(a[i],b[i]);
qsort(1,n);
f[1]:=a[1];len:=1;
for i:=2 to n do
begin
l:=1;r:=len+1;
while l< r do
if a[i]>=f[(l+r) shr 1] then r:=(l+r) shr 1
else l:=(l+r) shr 1+1;
f[r]:=a[i];if r>len then len:=r;
end;
writeln(len);
end;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator