比赛 noip_6 评测结果 AAAAAA
题目名称 打保龄球 最终得分 100
用户昵称 Achilles 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-10-08 21:32:29
显示代码纯文本
program bowling;
var
  s:string;
  sz:array[1..12,0..2] of integer;
  sav:array[1..10]of integer;
  a:array['1'..'9']of integer;
  t,i,n,n2:integer;
begin
  assign(input,'bowling.in');
  assign(output,'bowling.out');
  reset(input);
  rewrite(output);
  readln(s);
  n:=0;
  a['1']:=1;
  a['2']:=2;
  a['3']:=3;
  a['4']:=4;
  a['5']:=5;
  a['6']:=6;
  a['7']:=7;
  a['8']:=8;
  a['9']:=9;
  fillchar(sz,sizeof(sz),0);
  while s<>'' do
  begin
    n:=n+1;
    t:=pos(' ',s);
    t:=t-1;
    if t=-1 then t:=length(s);
    for i:=1 to t do
    begin
      if s[1]='/' then begin
        if i=1 then sz[n,i]:=10 else sz[n,i]:=10-sz[n,i-1];
      end
      else sz[n,i]:=a[s[1]];
      delete(s,1,1);
    end;
    sz[n,0]:=t;
    if s<>'' then delete(s,1,1);
  end;
  for i:=1 to n-2 do
  begin
    if sz[i,0]=1 then begin
      if sz[i+1,0]=2 then begin
        write(sz[i,1]+sz[i+1,1]+sz[i+1,2],' ');
        sav[i]:=sz[i,1]+sz[i+1,1]+sz[i+1,2];
       end
       else begin
         write(sz[i,1]+sz[i+1,1]+sz[i+2,1],' ');
         sav[i]:=sz[i,1]+sz[i+1,1]+sz[i+2,1];
       end;
    end
    else begin
      if sz[i,1]+sz[i,2]=10 then begin
        write(sz[i,1]+sz[i,2]+sz[i+1,1],' ');
        sav[i]:=sz[i,1]+sz[i,2]+sz[i+1,1];
      end
      else begin
        write(sz[i,1]+sz[i,2],' ');
        sav[i]:=sz[i,1]+sz[i,2];
      end;
    end;
  end;
  n2:=n-2;
  if sz[n-1,0]=1 then begin
    if n-1<=10 then
      if sz[n-1,0]=2 then begin
        if sz[n-1,1]+sz[n-1,2]=10 then begin
          write(sz[n-1,1]+sz[n-1,2]+sz[n,1],' ');
          n2:=n2+1;
          sav[n2]:=sz[n-1,1]+sz[n-1,2]+sz[n,1];
        end
        else begin
          write(sz[n-1,1]+sz[n-1,2],' ');
          n2:=n2+1;
          sav[n2]:=sz[n-1,1]+sz[n-1,2];
        end;
        if n<=10 then if (sz[n,0]=2)and(sz[n,1]+sz[n,2]<10) then begin
          write(sz[n-1,1]+sz[n-1,2]);
          n2:=n2+1;
          sav[n2]:=sz[n-1,1]+sz[n-1,2];
        end;
      end
      else begin
        if sz[n,0]=2 then begin
          write(sz[n-1,1]+sz[n,1]+sz[n,2]);
          n2:=n2+1;
          sav[n2]:=sz[n-1,1]+sz[n,1]+sz[n,2];
        end;
      end;
  end
  else begin
    if n-1<=10 then
      if sz[n-1,0]=1 then begin
        if sz[n,0]=2 then begin
          write(sz[n-1,1]+sz[n,1]+sz[n,2],' ');
          n2:=n2+1;
          sav[n2]:=sz[n-1,1]+sz[n,1]+sz[n,2];
          if (sz[n,0]=2)and(sz[n,1]+sz[n,2]<10) then begin
            write(sz[n,1]+sz[n,2]);
            n2:=n2+1;
            sav[n2]:=sz[n,1]+sz[n,2];
          end;
        end;
      end
      else begin
        if sz[n-1,1]+sz[n-1,2]<10 then begin
          write(sz[n-1,1]+sz[n-1,2]);
          n2:=n2+1;
          sav[n2]:=sz[n-1,1]+sz[n-1,2];
        end
        else begin
          write(sz[n-1,1]+sz[n-1,2]+sz[n,1]);
          n2:=n2+1;
          sav[n2]:=sz[n-1,1]+sz[n-1,2]+sz[n,1];
        end;
      end;
  end;
  writeln;
  for i:=2 to n2 do
    sav[i]:=sav[i]+sav[i-1];
  for i:=1 to n2 do
    write(sav[i],' ');
  close(input);
  close(output);
end.