记录编号 26757 评测结果 AAAAAAAAAA
题目名称 失落的猴子 最终得分 100
用户昵称 Gravatarwo shi 刘畅 是否通过 通过
代码语言 Pascal 运行时间 0.827 s
提交时间 2011-07-25 21:46:24 内存使用 5.85 MiB
显示代码纯文本
var
  n,m,k,i,j:longint;
  l,x1,x2,y1,y2:array[0..100000]of longint;
  color:array[0..1000,0..1000]of longint;

procedure up(now,shang,zuo,xia,you,all:longint);
var
    i,j:longint;
begin
  if now>k then
  begin
    for i:=shang to xia do
     for j:=zuo to you do
     color[i,j]:=all;
    exit;
  end;
  if (shang>x2[now])or(zuo>y2[now])or(xia<x1[now])or(you<y1[now]) then
  begin
    up(now+1,shang,zuo,xia,you,all);
    exit;
  end;
  if shang<x1[now] then
  begin
    up(now+1,shang,zuo,x1[now]-1,you,all);
    shang:=x1[now];
  end;
  if xia>x2[now] then
  begin
    up(now+1,x2[now]+1,zuo,xia,you,all);
    xia:=x2[now];
  end;
  if zuo<y1[now] then
  begin
    up(now+1,shang,zuo,xia,y1[now]-1,all);
    zuo:=y1[now];
  end;
  if you>y2[now] then
  begin
    up(now+1,shang,y2[now]+1,xia,you,all);
    you:=y2[now];
  end;
end;

begin
  assign(input,'lostmonkey.in'); reset(input);
  assign(output,'lostmonkey.out'); rewrite(output);
  readln(n,m,k);
  for i:=1 to k do
    readln(x1[i],y1[i],x2[i],y2[i],l[i]);
  for i:=x1[k] to x2[k] do
    for j:=y1[k] to y2[k] do
    color[i,j]:=l[k];
  for i:=k-1 downto 1 do
  up(i+1,x1[i],y1[i],x2[i],y2[i],l[i]);
  for i:=1 to n do
  begin
   for j:=1 to m do
   write(color[i,j]);
   writeln;
  end;
  close(input);
  close(output);
end.