记录编号 231 评测结果 AAAAAAAAAA
题目名称 [NOIP 2007]字符串的展开 最终得分 100
用户昵称 Gravatarzpl123 是否通过 通过
代码语言 Pascal 运行时间 10.000 s
提交时间 2008-07-17 21:03:34 内存使用 0.00 MiB
显示代码纯文本
program expand;
var
f1,f2:text;
s:string;
s1:array[1..10000]of char;
flag:boolean;
zz,p1,p2,p3:integer;
procedure start;
begin
assign(f1,'expand.in');
reset(f1);
readln(f1,p1,p2,p3);
read(f1,s);
close(f1);
end;{start}

procedure main;
var
i,j,l,p:integer;
begin
l:=length(s);
for i:=1 to l do
 begin
 flag:=true;
 if (s[i]='-')and(i>1) then
  begin
  if ((s[i-1] in ['0'..'9'])and(s[i+1] in ['0'..'9'])and(s[i-1]<s[i+1]))  then
     flag:=false;
  if ((s[i-1] in ['a'..'z'])and(s[i+1] in ['a'..'z'])and(s[i-1]<s[i+1]))  then
     flag:=false;
  if flag then
  begin
  inc(zz);
  s1[zz]:=s[i];
  end;{if flag}
  if flag=false then
  begin
  j:=0;
  while s[i+1]<>chr(ord(s[i-1])+1+j) do
   begin
   inc(j);
   for p:=1 to p2 do
    begin
    inc(zz);
    if p3=1 then
    case p1 of
     1:s1[zz]:=chr(ord(s[i-1])+j);
     2:if s[i-1] in ['a'..'z'] then
       s1[zz]:=chr(ord(s[i-1])+j-32)
       else
       s1[zz]:=chr(ord(s[i-1])+j);
     3:s1[zz]:='*';
    end{case}
            else
    case p1 of
      1:s1[zz]:=chr(ord(s[i+1])-j);
      2:if s[i-1] in ['a'..'z'] then
       s1[zz]:=chr(ord(s[i+1])-j-32)
       else
       s1[zz]:=chr(ord(s[i+1])-j);
      3:s1[zz]:='*';
    end{case};
    end;{for p}
   end;{while}
   end;{if not flag}
  end {if} else
           begin inc(zz);
           s1[zz]:=s[i];
           end;{else}
 end; {for i}
end;{main}

procedure print;
var
q:integer;
begin
assign(f2,'expand.out');
rewrite(f2);
for q:=1 to zz do
write(f2,s1[q]);
close(f2);
end;{print}

begin
start;
main;
print;
end.