比赛 20130725暑期B班1测 评测结果 MMMMMM
题目名称 黑叔 最终得分 0
用户昵称 三木公 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2012-07-18 11:29:17
显示代码纯文本
var
ab,i,j,k,a,b,c,cc,m,n:longint;
x:array[1..10000]of string;
r,s,t,bb:array[1..10000]of longint;
st:array[1..10000,1..10000]of longint;
o:char;

procedure ss(xx,yy:longint);
var i,j,m,n,l:longint;mm:string;
begin
i:=xx; j:=yy;
m:=s[(xx+yy) div 2];

repeat
while s[i]<m do inc(i);
while s[j]>m do dec(j);

if i<=j then begin
n:=s[i]; s[i]:=s[j]; s[j]:=n;
mm:=x[i];x[i]:=x[j];x[j]:=mm;
l:=t[i]; t[i]:=t[j]; t[j]:=l;
inc(i); dec(j); end;

until i>j;

if j>xx then ss(xx,j);
if i<yy then ss(i,yy);
end;

procedure ss1(xx,yy:longint);
var i,j,m,n,l,mmm:longint;mm:string;
begin
i:=xx; j:=yy;
m:=st[(xx+yy) div 2,k];

repeat
while st[i,k]<m do inc(i);
while st[j,k]>m do dec(j);

if i<=j then begin
n:=s[i]; s[i]:=s[j]; s[j]:=n;
mmm:=st[i,k];st[i,k]:=st[j,k];st[j,k]:=mmm;
mm:=x[i];x[i]:=x[j];x[j]:=mm;
l:=t[i]; t[i]:=t[j]; t[j]:=l;
inc(i); dec(j); end;

until i>j;

if j>xx then ss(xx,j);
if i<yy then ss(i,yy);
end;

begin
{assign(input,'hey.in');
reset(input);
assign(output,'hey.out');
rewrite(output);}

readln(a);
for i:=1 to a do
begin
 read(s[i]);
 read(o);
  repeat
  read(o);
  if o<>' ' then begin inc(j);x[i]:=x[i]+o;end;
  st[i,j]:=ord(x[i,j])-97;
  until o=' ';
 read(t[i]);
end;
for ab:=1 to a do
bb[ab]:=100;
ab:=1;
c:=1;
ss(1,a);
repeat
if s[c]=s[c+1] then begin
                    cc:=c;
                    repeat
                    inc(c);
                    if length(x[c])<bb[ab] then bb[ab]:=length(x[ab]);
                    until s[c]<>s[c+1];
                    inc(ab);
                    end else inc(c);

 if cc<>c then begin
               for k:=1 to bb[cc] do
               ss1(cc,c);
               end;
until c>=a;

i:=1;
repeat
r[i]:=s[i]+t[i];
s[i+1]:=r[i];
until i=a-1;
for i:=1 to a do
writeln(x[i],' went out at time ',s[i]);


{close(input);
close(output);}
end.