比赛 20120705 评测结果 AAAAATTTTT
题目名称 绘画 最终得分 50
用户昵称 fuhao 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2012-07-05 11:36:36
显示代码纯文本
const maxm=100001; maxn=1001;
var
 x1,x2,y1,y2,tot,now,x,color,kx,ky,num,n,k,m,i,l:longint;
 s,ss:string;
 a,next,c:array[0..maxm] of longint;
 map:array[0..maxn,0..maxn] of longint;
 xx,yy:array[0..maxm,1..2] of longint;
 procedure init;
 begin
  readln(color,x1,y1,x2,y2);
  inc(tot); next[tot]:=a[now];
  a[now]:=tot; c[tot]:=color;
  xx[tot,1]:=x1; xx[tot,2]:=x2;
  yy[tot,1]:=y1; yy[tot,2]:=y2;
 end;
 procedure save;
 begin inc(now); a[now]:=a[now-1]; end;
 procedure load;
 var x:longint;
 begin readln(x); a[now]:=a[x]; end;
 procedure paint;
 var i:longint;
 begin
  i:=a[now];
  while i<>0 do
   begin
    x1:=xx[i,1]; x2:=xx[i,2];
    y1:=yy[i,1]; y2:=yy[i,2];
    kx:=x1; ky:=y1;
    while (kx<=x2) do
     begin
      while (ky<=y2) do
       begin
        if map[kx,ky]=1 then
         begin
          map[kx,ky]:=c[i];
          num:=num+1;
         end;
        ky:=ky+2;
       end;
      kx:=kx+1;
      ky:=y1+(kx-x1) mod 2;
     end;
   i:=next[i];
   if num=n*n then break;
  end;
 end;
 procedure print;
 var i,j:longint;
 begin
  for i:=0 to n-1 do
   begin
    for j:=0 to n-2 do write(map[i,j],' ');
    writeln(map[i,n-1]);
   end;
 end;
begin
 assign(input,'drawing.in'); reset(input);
 assign(output,'drawing.out'); rewrite(output);
 readln(n,k,m); now:=1;
 for i:=0 to n-1 do
  for l:=0 to n-1 do map[i,l]:=1;
 for i:=1 to m do
  begin
   l:=0;
   repeat
    inc(l);
    read(s[l]);
    if s[l]='S' then
     begin
      readln(ss);
      save;
      break;
     end;
   until s[l]=' ';
   s[0]:=chr(l-1);
   if s='PAINT' then init;
   if s='LOAD' then load;
  end;
 paint;
 print;
 close(input); close(output);
end.