比赛 noip_6 评测结果 WWWWWW
题目名称 打保龄球 最终得分 0
用户昵称 zhai 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-10-26 11:08:32
显示代码纯文本
program bowling;
  const
    max=15;
  type
    sx=array[1..max]of string;
    sy=array[1..max]of integer;
    sz=array[1..max]of longint;
  var
    f1,f2:text;
    a:sx;
    b:sy;
    c:sz;
    n:integer;
    procedure ini;
      var
        i,l:integer;
        s:string;
      begin
        fillchar(a,sizeof(a),0);
        fillchar(b,sizeof(b),0);
        fillchar(c,sizeof(c),0);
        assign(f1,'bowling.in');reset(f1);
        assign(f2,'bowling.out');rewrite(f2);
        readln(f1,s);
        s:=s+' ';
        close(f1);
        n:=0;
        while s<>'' do begin
          inc(n);
          l:=pos(' ',s);
          a[n]:=copy(s,1,l-1);
          delete(s,1,l);
        end;
      end;
    procedure main;
      var
        i,j,h:integer;
        k,l,m:string;
      begin
        for i:=1 to n-2 do begin
          k:=a[i];h:=0;
          if k='/' then begin
            h:=10;
            if a[i+1]='/' then begin
              if a[i+2]='/'then begin
                h:=30;
              end else begin
                h:=20+ord(a[i+2][1])-48;
              end;
            end else begin
              l:=a[i+1][1];
              m:=a[i+1][2];
              h:=h+ord(l[1])-48;
              if m[1]='/' then begin
                h:=20;
              end else begin
              h:=h+ord(m[1])-48;
              end;
            end;
          end else begin
            h:=ord(k[1])-48;
            l:=a[i+1];
            if k[2]='/' then begin
              h:=10;
              if l[1]='/' then begin
                h:=20;
              end else begin
                h:=h+ord(l[1])-48;
              end;
            end else begin
              h:=h+ord(k[2])-48;
            end;
          end;
          b[i]:=h;
        end;
        if a[i+1]<>'/' then begin
          if a[i+1][2]='/' then begin
            if a[i+2][1]='/' then begin
              b[i+1]:=20;
            end else begin
              b[i+1]:=ord(a[i+2][1])-38;
            end;
          end else begin
            if a[i+2]='/' then begin b[i+1]:=20;end
            else begin
              b[i+1]:=ord(a[i+1][1])+ord(a[i+1][2])+ord(a[i+2][1])-144;
            end;
          end;
          j:=i+1;
          if a[i+1]='/' then begin
            if a[i+2]<>'/'then begin
              l:=a[i+2][1];m:=a[i+2][2];
              if m='/' then begin
                b[i+1]:=20;
              end
              else begin
                b[i+1]:=10+ord(a[i+2][1])+ord(a[i+2][2])-96;
              end;
            end;
            j:=i+1;
          end;
          if (a[i+2][1]<>'/')and(a[i+2][2]<>'/') then begin
            b[i+2]:=ord(a[i+2][1])+ord(a[i+2][2])-96;
            j:=i+2;
          end;
        end;
        c[1]:=b[1];
        j:=1;
        while b[j]<>0 do inc(j);
        for i:=2 to j do c[i]:=c[i-1]+b[i];
        n:=j;
      end;
    procedure pr;
      var
        i:integer;
      begin
        for i:=1 to n do write(f2,b[i],' ');
        writeln(f2);
        for i:=1 to n do write(f2,c[i],' ');
        close(f2);
      end;
  begin
    ini;
    main;
    pr;
  end.