分析:
直接模拟,注意有坑,细心点就AC了。
代码:
var
s,a:array [1..51] of ansistring;
n,i,j,k,p:longint;
e,h:ansistring;
flag:boolean;
procedure lxf;
begin
write('|');
write(' ');
end;
procedure wjp;
begin
write('|');
write('----');
end;
procedure qsort(l,r:longint);
var
i,j:longint;
key,temp:ansistring;
begin
if l>=r then exit;
i:=l;j:=r;
key:=s[l+random(r-l+1)];
repeat
while (s[i]<key) do inc(i);
while (s[j]>key) do dec(j);
if i<=j then
begin
temp:=s[i];s[i]:=s[j];s[j]:=temp;
inc(i);dec(j);
end;
until i>j;
qsort(l,j);
qsort(i,r);
end;
begin
readln(n);
for i:=1 to n do
begin
readln(s[i]);
s[i]:=s[i]+'/';
end;
qsort(1,n);
e:=s[1];
i:=0;
while pos('/',e)>0 do
begin
inc(i);
p:=pos('/',e);
h:=copy(e,1,p-1);
a[i]:=h;
delete(e,1,p);
for j:=1 to i-2 do lxf;
if i>1 then wjp;
writeln(h);
end;
for k:=2 to n do
begin
e:=s[k]; i:=0; flag:=true;
while pos('/',e)>0 do
begin
inc(i);
p:=pos('/',e);
h:=copy(e,1,p-1);
delete(e,1,p);
if a[i]<>h then flag:=false;
if flag then continue;
a[i]:=h;
for j:=1 to i-2 do lxf;
if i>1 then wjp;
writeln(h);
end;
end;
end.