记录编号 39153 评测结果 AWAAATTTTT
题目名称 绘画 最终得分 40
用户昵称 Gravatarzhangchi 是否通过 未通过
代码语言 Pascal 运行时间 5.420 s
提交时间 2012-07-05 14:53:19 内存使用 10.55 MiB
显示代码纯文本
var
  i,j,k,n,m,tot,p,s,num,tail,mark,temp,pp,cc,ii,jj:longint;
  ch:char;
  map:array[0..1,0..1000,0..1000] of longint;
  which,work,save:array[1..100001] of longint;
  opt:array[1..100001,0..4] of longint;
  hang:array[1..100001] of longint;
  print:array[1..100001] of boolean;
  kind:array[1..100001] of longint;
  procedure cover(k,up,left,down,right:longint);
  begin
    while (k<=m)and((not print[k])or(kind[i]<>p)or(up>opt[work[k],3])or(left>opt[work[k],4])or(down<opt[work[k],1])or(right<opt[work[k],2])) do inc(k);
    if k>=m+1 then
      begin
        for ii:=up to down do
          for jj:=left to right do
            map[pp,ii,jj]:=cc;
        exit;
      end;
    if up<=opt[work[k],1] then begin cover(k+1,up,left,opt[work[k],1],right); up:=opt[work[k],1]; end;
    if down>=opt[work[k],3] then begin cover(k+1,opt[work[k],3],left,down,right); down:=opt[work[k],3]; end;
    if left<=opt[work[k],2] then begin cover(k+1,up,left,down,opt[work[k],2]); left:=opt[work[k],2]; end;
    if right>=opt[work[k],4] then begin cover(k+1,up,opt[work[k],4],down,right); right:=opt[work[k],4]; end;
  end;
begin
  assign(input,'drawing.in'); reset(input);
  assign(output,'drawing.out'); rewrite(output);
  readln(n,k,m);
  for i:=1 to m do
    begin
      read(ch);
      case ch of
        'P':begin
              read(ch); read(ch); read(ch); read(ch);
              inc(p);
              hang[p]:=i;
              readln(opt[p,0],opt[p,1],opt[p,2],opt[p,3],opt[p,4]);
              which[i]:=1;
              work[i]:=p;
            end;
        'S':begin
              readln;
              inc(s);
              save[s]:=hang[p];
              which[i]:=2;
              work[i]:=p;
            end;
        'L':begin
              read(ch); read(ch); read(ch);
              readln(num);
              which[i]:=3;
              work[i]:=save[num];
            end;
      end;
    end;
  i:=m;
  while i>=1 do
    begin
      case which[i] of
        1:begin print[i]:=true; kind[i]:=(opt[work[i],1]+opt[work[i],2]) mod 2; dec(i); end;
        2:dec(i);
        3:i:=work[i];
      end;
    end;
  pp:=0; cc:=1;
  cover(1,0,0,n-1,n-1);
  pp:=1; cc:=1;
  cover(1,0,0,n-1,n-1);
  for i:=1 to m do
    if print[i] then
      begin
        p:=work[i];
        pp:=(opt[p,1]+opt[p,2]) mod 2;
        cc:=opt[p,0];
        cover(i+1,opt[p,1],opt[p,2],opt[p,3],opt[p,4]);
      end;
  for i:=0 to n-1 do
    begin
      for j:=0 to n-2 do
        if (i+j) mod 2=0 then write(map[0,i,j],' ') else write(map[1,i,j],' ');
      if (i+n-1) mod 2=0 then writeln(map[0,i,n-1]) else writeln(map[1,i,n-1]);
    end;
  close(input); close(output);
end.