记录编号 252 评测结果 AAAAAAAAAA
题目名称 [NOIP 2007]字符串的展开 最终得分 100
用户昵称 Gravatarzhai 是否通过 通过
代码语言 Pascal 运行时间 10.000 s
提交时间 2008-07-17 20:41:08 内存使用 0.00 MiB
显示代码纯文本
program expand(f1,f2);
  var
    f1,f2:text;
    p1,p2,p3,i,l,j,k,g,h,d:integer;
    f,x:boolean;
    c1,c2:char;
    a:array[1..10000]of char;
    s:string;
    procedure init;
      begin
        assign(f1,'expand.in');reset(f1);
        assign(f2,'expand.out');rewrite(f2);
        readln(f1,p1,p2,p3);
        readln(f1,s);
        close(f1);
      end;
  begin
    init;
    l:=length(s);
    g:=1;
    for i:=1 to l do begin
      f:=true;x:=true;
      if (s[i]='-')and(i<>1)then begin
        c1:=s[i-1];
        c2:=s[i+1];
        if ord(c2)-ord(c1)=1 then x:=false;
        if (ord(c2)-ord(c1)>1)and(((c1 in ['0'..'9'])and(c2 in['0'..'9']))
         or((c1 in ['a'..'z'])and(c2 in['a'..'z'])))
        then f:=false;
        if f=false then begin
          if p1=3 then
            for h:=ord(c1)+1 to ord(c2)-1 do begin
              k:=g;
              for j:=0 to p2-1 do begin
                a[j+k]:='*';
                inc(g);
              end
            end
          else begin
            if (p3=1)and(ord(c1)>57) then
              case p1 of
                1:for h:=ord(c1)+1 to ord(c2)-1 do begin
                    k:=g;
                    for j:=0 to p2-1 do begin
                      a[j+k]:=chr(h);
                      inc(g);
                    end;
                  end;
                2:for h:=ord(c1)+1 to ord(c2)-1 do begin
                    k:=g;
                    for j:=0 to p2-1 do begin
                      a[j+k]:=chr(h-32);
                      inc(g);
                    end;
                  end;
              end;
            if (p3=1)and(ord(c1)<65) then
              for h:=ord(c1)+1 to ord(c2)-1 do begin
                k:=g;
                for j:=0 to p2-1 do begin
                  a[j+k]:=chr(h);
                  inc(g);
                end
              end;
            if (p3=2)and(ord(c1)>57) then
              case p1 of
                1:for h:=ord(c2)-1 downto ord(c1)+1 do begin
                    k:=g;
                    for j:=0 to p2-1 do begin
                      a[j+k]:=chr(h);
                      inc(g);
                    end;
                  end;
                2:for h:=ord(c2)-1 downto ord(c1)+1 do begin
                    k:=g;
                    for j:=0 to p2-1 do begin
                      a[j+k]:=chr(h-32);
                      inc(g);
                    end;
                  end;
              end;
            if (p3=2)and(ord(c1)<65) then
              for h:=ord(c2)-1 downto ord(c1)+1 do begin
                k:=g;
                for j:=0 to p2-1 do begin
                  a[j+k]:=chr(h);
                  inc(g);
                end
              end;
          end;
        end;
      end;
      if f and x then begin
          a[g]:=s[i];
          inc(g);
      end;
    end;
    for i:=1 to g do write(f2,a[i]);
    close(f2);
  end.