记录编号 11213 评测结果 AAAAAAAAAA
题目名称 [NOIP 2007]字符串的展开 最终得分 100
用户昵称 Gravatarsywgz 是否通过 通过
代码语言 Pascal 运行时间 0.029 s
提交时间 2009-07-17 16:42:24 内存使用 0.11 MiB
显示代码纯文本
program expand;
var
 ch:char;
 p1,p2,p3:integer;
 s:string;

procedure init;
 begin
  assign(input,'expand.in');reset(input);
  assign(output,'expand.out');rewrite(output);
  readln(p1,p2,p3);
  readln(s);
  close(input);
 end;

procedure expand(x,y:char;a,b,c:integer);
 var
  i,z:char;
  j:integer;
 begin
  case c of
   1:begin
     i:=succ(x);
     while i<y do begin
      z:=i;
      if a=2 then if z in ['a'..'z'] then z:=chr(ord(z)-97+65);
      if a=3 then z:='*';
      for j:=1 to b do write(z);
      i:=succ(i);
     end;
     end;
   2:begin
     i:=pred(y);
     while i>x do begin
      z:=i;
      if a=2 then if z in ['a'..'z'] then z:=chr(ord(z)-97+65);
      if a=3 then z:='*';
      for j:=1 to b do write(z);
      i:=pred(i);
     end;
     end;
   end;
  end;

procedure main;
 var
  i,l:integer;
  t1,t2:char;
 begin
  l:=length(s);
  write(s[1]);
  for i:=2 to l-1 do begin
    if s[i]<>'-'
     then write(s[i])
     else begin
      t1:=s[i-1]; t2:=s[i+1];
      if (t1 in ['a'..'z']) and (t2 in ['a'..'z']) or (t1 in ['0'..'9'])and(t2 in ['0'..'9'])
       then begin
        if (t1>=t2) then write('-')
                    else expand(t1,t2,p1,p2,p3);
       end
       else write('-');
     end;
  end;
  writeln(s[l]);
 end;

begin
 init;
 main;
 close(output);
end.