讨论 / 本人第一次发问!诚求帮忙!!非常感谢!感激不尽啊!
Sun 2008-11-06 03:30:00
点我顶贴 收藏 删除
program il;

type

as=record

m,f:string;

end;

var

y:as;

s:array[0..5000] of as;

i,j,n:longint;

function p(a,b:string):boolean;

var

i,j,l1,l2:longint;

begin

l1:=length(a);

l2:=length(b);

if l1>l2 then begin p:=true; exit; end;

if l1<l2 then begin p:=false; exit; end;

for i:=1 to l1 do

begin

if a[i]>b[i] then begin p:=true; exit;end;

if a[i]<b[i] then begin p:=false; exit;end;

end;

end;

procedure h(i,m:integer);

var

y:as;

begin

while i*2<=m do

begin

i:=i*2;

if (i<m)and((p(s[i+1].f,s[i].f))or((s[i+1].f=s[i].f)and(p(s[i+1].m,s[i].m))))then inc(i);

if (p(s[i].f,s[i div 2].f))or((s[i].f=s[i div 2].f)and(p(s[i].m,s[i div 2].m))) then

begin

y:=s[i];

s[i]:=s[i div 2];

s[i div 2]:=y;

end

else break;

end;

end;

begin

readln(n);

for i:=1 to n do

begin

readln(s[i].m);

readln(s[i].f);

if s[i].f[1]=’0’ then

for j:=1 to length(s[i].f) do

begin

if s[i].f[j]=’0’ then delete(s[i].f,j,1);

if s[i].f<>’0’ then break;

end;

end;

for i:=n div 2 downto 1 do

h(i,n);

for i:=n downto 2 do

begin

y:=s[i];

s[i]:=s[1];

s[1]:=y;

h(1,i-1);

end;

for i:=n downto 1 do

writeln(s[i].m);

end.

Unaccepted

测评机: Xeost[5]

得分: 80分

提交日期: 2008-11-6 17:03:00

有效耗时: 1625毫秒

测试结果1: 通过本测试点|有效耗时187:ms

测试结果2: 通过本测试点|有效耗时172:ms

测试结果3: 通过本测试点|有效耗时172:ms

测试结果4: 测试结果错误.

测试结果5: 通过本测试点|有效耗时219:ms

测试结果6: 通过本测试点|有效耗时219:ms

测试结果7: 通过本测试点|有效耗时203:ms

测试结果8: 通过本测试点|有效耗时250:ms

测试结果9: 通过本测试点|有效耗时203:ms

测试结果10:测试结果错误.

第四个和第十个点,过不了,诚求讲解!谢谢!感激不尽!!!!!!!!!!!!!

仰望!!!!

#1 hades@2008-11-06 02:37:00
回复 删除
这个题?

哦。

过不了,值得考虑一下。

#2 xiaokeke@2008-11-06 03:30:00
回复 删除
首位可能有前导0,是不是没有判断这个情况?
查看更多回复
提交回复