记录编号 6908 评测结果 AAAAAAAAAA
题目名称 [NOIP 2007]字符串的展开 最终得分 100
用户昵称 Gravatarlc 是否通过 通过
代码语言 Pascal 运行时间 0.022 s
提交时间 2008-11-05 12:23:40 内存使用 0.11 MiB
显示代码纯文本
program expand;
 type
   stype=ansistring;
 var
    p1,p2,p3:integer;
    i:longint;
    s,ans:stype;

function solve(a,b:char):stype;
 var
    s1,s2:stype;
    i,j:longint;

 begin
  s1:=''; s2:='';
  case p1 of
   1:    begin
          for i:=ord(a)+1 to ord(b)-1 do
            for j:=1 to p2 do
            s1:=s1+chr(i);
         end;

   2:    begin
          for i:=ord(a)+1 to ord(b)-1 do
            for j:=1 to p2 do
            if a in['a'..'z']
            then s1:=s1+chr(i-32)
            else s1:=s1+chr(i);
          end;

    3:    begin
           for i:=ord(a)+1 to ord(b)-1 do
             for j:=1 to p2 do
             s1:=s1+'*';
          end;
     end; //case

  if p3=1 then s2:=s1
          else for i:=1 to length(s1) do
               s2:=s2+s1[length(s1)-i+1];
  exit(S2);
 end;


begin
 assign(input,'expand.in');
 assign(output,'expand.out');
 reset(input); rewrite(output);
 readln(p1,p2,p3);
 readln(s); ans:=ans+s[1];
 for i:=2 to length(s)-1 do
   begin
     ans:=ans+s[i];
     if s[i]='-'
      then
           if (s[i-1] in['a'..'z']) and (s[i+1] in['a'..'z'])
           or (s[i-1] in['0'..'9']) and (s[i+1] in['0'..'9'])
             then if s[i-1]<s[i+1]
                  then  begin
                        delete(ans,length(ans),1);
                        ans:=ans+solve(s[i-1],s[i+1])
                        end;
    end;
  ans:=ans+s[length(s)];
  writeln(ans);
 close(input); close(output);
end.