记录编号 |
39189 |
评测结果 |
AAAAAAAAAA |
题目名称 |
绘画 |
最终得分 |
100 |
用户昵称 |
wo shi 刘畅 |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
1.977 s |
提交时间 |
2012-07-05 22:36:34 |
内存使用 |
25.74 MiB |
显示代码纯文本
var
p,n,k,j,m,i,tot:longint;
color:array[0..1001,0..1001]of longint;
s:string;
ch:char;
save,load,belong,xx1,num,
yy1,xx2,yy2,cc:array[0..300000]of longint;
x1,y1,x2,y2,c:array[0..1,0..300000]of longint;
procedure paint(h1,t1,h2,t2,col,p:longint);
var
i,j:longint;
begin
for i:=h1 to h2 do
for j:=t1 to t2 do
if (i xor j) and 1=p then
color[i,j]:=col;
end;
procedure up(k,h1,t1,h2,t2,col,p:longint);
begin
while (k>0)and((h1>x2[p,k])or(h2<x1[p,k])or(t1>y2[p,k])or(t2<y1[p,k]))
do dec(k);
if k=0 then begin paint(h1,t1,h2,t2,col,p); exit; end;
if h1<x1[p,k] then begin up(k-1,h1,t1,x1[p,k]-1,t2,col,p); h1:=x1[p,k]; end;
if h2>x2[p,k] then begin up(k-1,x2[p,k]+1,t1,h2,t2,col,p); h2:=x2[p,k]; end;
if t1<y1[p,k] then begin up(k-1,h1,t1,h2,y1[p,k]-1,col,p); t1:=y1[p,k]; end;
if t2>y2[p,k] then begin up(k-1,h1,y2[p,k]+1,h2,t2,col,p); t2:=y2[p,k]; 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
s:='';
read(ch);
repeat
s:=s+ch;
read(ch);
until not (ch in ['A'..'Z']);
if s='PAINT' then
begin
readln(cc[i],xx1[i],yy1[i],xx2[i],yy2[i]);
inc(xx1[i]);
inc(yy1[i]);
inc(xx2[i]);
inc(yy2[i]);
belong[i]:=1;
end;
if s='SAVE' then
begin
readln;
belong[i]:=2;
inc(tot);
save[tot]:=i;
end;
if s='LOAD' then
begin
readln(load[i]);
belong[i]:=3;
end;
end;
i:=m;
while i>0 do
begin
if belong[i]=3 then
begin
i:=save[load[i]]-1;
continue;
end
else if belong[i]=1 then
begin
p:=(xx1[i] xor yy1[i]) and 1;
inc(num[p]);
x1[p,num[p]]:=xx1[i];
x2[p,num[p]]:=xx2[i];
y1[p,num[p]]:=yy1[i];
y2[p,num[p]]:=yy2[i];
c[p,num[p]]:=cc[i];
end;
dec(i);
end;
for i:=1 to n do
for j:=1 to n do
color[i,j]:=1;
for i:=1 to num[0] do up(i-1,x1[0,i],y1[0,i],x2[0,i],y2[0,i],c[0,i],0);
for i:=1 to num[1] do up(i-1,x1[1,i],y1[1,i],x2[1,i],y2[1,i],c[1,i],1);
for i:=1 to n do
begin
for j:=1 to n do
write(color[i,j],' ');
writeln;
end;
close(input);
close(output);
end.