比赛 201001-line 评测结果 AAAAAAAAAA
题目名称 编码问题 最终得分 100
用户昵称 ybh 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-01-18 19:48:57
显示代码纯文本
program code;
var
  a,b:array[0..101] of integer;
  c:array[0..101] of boolean;
  m,n,i,j,k,p,s:integer;
begin
  assign(input,'code.in');
  reset(input);
  assign(output,'code.out');
  rewrite(output);
  readln(m,n);
  for k:=1 to m do
  begin
    readln(s);
    fillchar(a,sizeof(a),0);
    fillchar(b,sizeof(b),0);
    if s=1 then
    begin
      for i:=1 to n do
        read(a[i]);
      readln;
      for i:=1 to n do
      begin
        for j:=1 to i-1 do
          if a[i]>a[j]
            then inc(b[i])
      end;
      for i:=1 to n do
        write(b[i],' ');
      writeln
    end
    else
    begin
      for i:=1 to n do
        read(b[i]);
      readln;
      fillchar(c,sizeof(c),true);
      for i:=n downto 1 do
      begin
        p:=0;
        for j:=0 to n-1 do
          if c[j] then
          begin
            inc(p);
            if p>b[i] then
            begin
              a[i]:=j;
              c[j]:=false;
              break
            end
          end
      end;
      for i:=1 to n do
        write(a[i],' ');
      writeln
    end
  end;
  close(input);
  close(output)
end.