查看状态 Show Status
题目:争分
状态: Unaccepted
测评机: Xeost[5]
得分: 90分
提交日期: 2010-7-18 23:42:00
有效耗时: 1687毫秒
测试结果1: 通过本测试点|有效耗时156ms
测试结果2: 通过本测试点|有效耗时156ms
测试结果3: 通过本测试点|有效耗时156ms
测试结果4: 通过本测试点|有效耗时172ms
测试结果5: 通过本测试点|有效耗时219ms
测试结果6: 通过本测试点|有效耗时219ms
测试结果7: 通过本测试点|有效耗时203ms
测试结果8: 通过本测试点|有效耗时219ms
测试结果9: 通过本测试点|有效耗时187ms
测试结果10: 测试结果错误.错误结果为:CYtMTUyl0chGyt.........
var
n,i,j,x:longint;
a,b:array[1..5000]of ansistring;
function zhenli(p,q:string):boolean;
begin
if p=q then exit(false);
if length(p)<length(q) then exit(false);
if length(p)>length(q) then exit(true);
if length(p)=length(q) then if p>q then exit(true) else exit(false);
end;
procedure sort(l,r:longint);
var i,j:longint;
x,y:string;
begin
i:=l;j:=r;x:=b[(l+r)div 2];
repeat
while zhenli(b[i],x) do inc(i);
while zhenli(x,b[j]) do dec(j);
if i<=j then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
y:=b[i];b[i]:=b[j];b[j]:=y;
inc(i);
dec(j);
end;
until i>j;
if i<r then sort(i,r);
if l<j then sort(l,j);
end;
begin
readln(n);
for i:=1 to n do begin
readln(a[i]);
readln(b[i]);
while b[i][1]='0' do delete(b[1],1,1);
end;
sort(1,n);
for i:=1 to n do
writeln(a[i]);
readln;
readln;
end.
如果我的程序有漏洞,还望大牛拔刀相助
var
n,i,j,x:longint;
a,b:array[1..5000]of ansistring;
function zhenli(p,q:string):boolean;
begin
if p=q then exit(false);
if length(p)<length(q) then exit(false);
if length(p)>length(q) then exit(true);
if length(p)=length(q) then if p>q then exit(true) else exit(false);
end;
procedure sort(l,r:longint);
var i,j:longint;
x,y:string;
begin
i:=l;j:=r;x:=b[(l+r)div 2];
repeat
while zhenli(b[i],x) do inc(i);
while zhenli(x,b[j]) do dec(j);
if i<=j then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
y:=b[i];b[i]:=b[j];b[j]:=y;
inc(i);
dec(j);
end;
until i>j;
if i<r then sort(i,r);
if l<j then sort(l,j);
end;
begin
readln(n);
for i:=1 to n do begin
readln(a[i]);
readln(b[i]);
end;
sort(1,n);
for i:=1 to n do
writeln(a[i]);
readln;
readln;
end.
var
n,i,j,x,l:longint;
a,b:array[1..5000]of ansistring;
function zhenli(p,q:string):boolean;
begin
if p=q then exit(false);
if length(p)<length(q) then exit(false);
if length(p)>length(q) then exit(true);
if length(p)=length(q) then if p>q then exit(true) else exit(false);
end;
procedure sort(l,r:longint);
var i,j:longint;
x,y,t:string;
begin
i:=l;j:=r;x:=a[(i+j)div 2];y:=b[(i+j)div 2];
repeat
while zhenli(b[i],y) or((b[i]=y) and zhenli(x,a[i])) do inc(i);
while zhenli(y,b[j]) or((b[j]=y) and zhenli(a[j],x)) do dec(j);
if i<=j then
begin
t:=a[i];
a[i]:=a[j];
a[j]:=t;
t:=b[i];b[i]:=b[j];b[j]:=t;
inc(i);
dec(j);
end;
until i>j;
if i<r then sort(i,r);
if l<j then sort(l,j);
end;
begin
readln(n);
for i:=1 to n do begin
readln(a[i]);
readln(b[i]);
while b[i][1]='0' do
delete(b[i],1,1);
end;
sort(1,n);
for i:=1 to n do
writeln(a[i]);
readln;
readln;
end.