比赛 |
20110725 |
评测结果 |
TTTTTTTTTT |
题目名称 |
失落的猴子 |
最终得分 |
0 |
用户昵称 |
苏轼 |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2011-07-25 10:16:20 |
显示代码纯文本
#include <cstdio>
#include <list>
using namespace std;
const int MAXN=1005;
const int MAXL=10;
#define pb push_back
struct Rect
{
int x1,x2,y1,y2;
Rect(int _x1,int _x2,int _y1,int _y2):
x1(_x1),x2(_x2),y1(_y1),y2(_y2){}
Rect(){}
};
inline void sub(const Rect &a,const Rect &b,list <Rect> &v)
{
if (a.x1<=b.x1-1)
v.pb(Rect(a.x1,b.x1-1,a.y1,a.y2));
if (a.y1<=b.y1-1)
v.pb(Rect(b.x1,b.x2,a.y1,b.y1-1));
if (b.y2+1<=a.y2)
v.pb(Rect(b.x1,b.x2,b.y2+1,a.y2));
if (b.x2+1<=a.x2)
v.pb(Rect(b.x2+1,a.x2,a.y1,a.y2));
}
list<Rect> v[MAXL];
Rect ask[MAXN];
int color[MAXN];
int a[MAXN][MAXN];
int main()
{
freopen("lostmonkey.in","r",stdin);
freopen("lostmonkey.out","w",stdout);
int N,M,K;
scanf("%d%d%d",&N,&M,&K);
v[0].pb(Rect(1,N,1,M));
for(int i=0;i<K;i++)
scanf("%d%d%d%d%d",&ask[i].x1,&ask[i].y1,&ask[i].x2,&ask[i].y2,&color[i]);
list<Rect> q;
for(int i=K-1;i>=0;i--)
{
Rect *now=&ask[i];
int to=color[i];
for(list<Rect>::iterator it=v->begin();it!=v->end();)
if (it->x1<=now->x2 && it->x2>=now->x1 && it->y1<=now->y2 && it->y2>=now->y1)
{
Rect expand(max(it->x1,now->x1),min(it->x2,now->x2),max(it->y1,now->y1),min(it->y2,now->y2));
sub(*it,expand,q);
v[to].pb(expand);
it=v->erase(it);
}
else
it++;
v[0].splice(v[0].end(),q);
}
for(int i=0;i<10;i++)
for(list<Rect>::iterator it=v[i].begin();it!=v[i].end();it++)
for(int x=it->x1-1;x<it->x2;x++)
for(int y=it->y1-1;y<it->y2;y++)
a[x][y]=i;
for(int i=0;i<N;i++)
{
for(int j=0;j<M;j++)
printf("%d",a[i][j]);
printf("\n");
}
return 0;
}