hdu 3265 Posters
来源:互联网 发布:ge矩阵分析法案例 编辑:程序博客网 时间:2024/05/21 14:04
题目
线段树求面积的并,虽然每个矩形有个孔,但我们可以把他分成四个矩形,然后就.....
环境不支持__int64,敲完编译才发现==
#include <cstdio>#include <cstring>#include <map>#include <algorithm>using namespace std;#define N 50005#define __int64 long longinline int input(){ bool IsN=0; int ret=0; char c; c=getchar(); while(c<'0'||c>'9') { if(c=='-') IsN=1; c=getchar(); } while(c>='0'&&c<='9') { ret=ret*10+c-'0'; c=getchar(); } return IsN?-ret:ret;}map<int,int>m;int n,x,y,x2,y2,x3,y3,x4,y4,k,num,X[N];int h[N];struct Line{ int s,t,y; int cov;}l[N*8];bool cmp(Line i,Line j){ return i.y<j.y;}struct node{ int l,r,cov; __int64 len;}root[50000*10];inline void build(int t,int x,int y){ root[t].l=x; root[t].r=y; root[t].len=root[t].cov=0; if(x+1==y) return; int m=(x+y)>>1; build(t*2,x,m); build(t*2+1,m,y);}inline void Push_up(int t){ if(root[t].cov>0) root[t].len=h[root[t].r]-h[root[t].l]; else if(root[t].l+1==root[t].r) root[t].len=0; else root[t].len=root[t*2].len+root[t*2+1].len;}inline void Modefiy(int t,int x,int y,int cov){ int l=root[t].l; int r=root[t].r; if(r<x||l>y) return; if(x<=l&&r<=y) { root[t].cov+=cov; Push_up(t); return; } Modefiy(t*2,x,y,cov); Modefiy(t*2+1,x,y,cov); Push_up(t);}int main(){ while(scanf("%d",&n)&&n) { m.clear(); // h.clear(); k=1; num=0; for(int i=1;i<=n;i++) { x=input(),y=input(),x2=input(),y2=input(),x3=input(),y3=input(),x4=input(),y4=input(); l[num].s=x,l[num].t=x4,l[num].y=y,l[num++].cov=1; l[num].s=x,l[num].t=x4,l[num].y=y3,l[num++].cov=-1; l[num].s=x4,l[num].t=x2,l[num].y=y,l[num++].cov=1; l[num].s=x4,l[num].t=x2,l[num].y=y4,l[num++].cov=-1; l[num].s=x3,l[num].t=x2,l[num].y=y4,l[num++].cov=1; l[num].s=x3,l[num].t=x2,l[num].y=y2,l[num++].cov=-1; l[num].s=x,l[num].t=x3,l[num].y=y3,l[num++].cov=1; l[num].s=x,l[num].t=x3,l[num].y=y2,l[num++].cov=-1; m[x]=1; m[x2]=1; m[x3]=1; m[x4]=1; } map<int,int>::iterator it=m.begin(); for(;it!=m.end();++it) { X[(*it).first]=k; h[k]=(*it).first; k++; } sort(l,l+num,cmp); build(1,1,k); __int64 ans=0; for(int i=0;i<num-1;i++) { int a=X[l[i].s]; int b=X[l[i].t]; if(a!=b) Modefiy(1,a,b,l[i].cov); ans+=root[1].len*(l[i+1].y-l[i].y); } printf("%I64d\n",ans); } return 0;}
- hdu 3265 Posters
- HDU 3265 - Posters
- hdu 3265 Posters
- HDU 3265 Posters
- HDU 3265 Posters
- HDU-3265-Posters
- HDU 3265 Posters
- HDU 3265 Posters
- hdu 3265 Posters
- zoj 3273 || hdu 3265 Posters
- hdu 3265 Posters(扫描线)
- hdu 3265 Posters(扫描线)
- hdu 3265 Posters 线段树+扫描线
- HDU 3265 Posters(线段树:扫描线)
- HDU 3265 Posters(线段树)
- HDU 3265 Posters (线段树-扫描线)
- HDU 3265 Posters (线段树+扫描线+矩形分割)
- HDU 3265 Posters(面积并模板题)
- a标签的href和onclick 的事件的区别
- 完全卸载oracle11g步骤
- airplay解析
- 推荐一个值得尊敬老外Al-Farooque Shubho的两篇文章---对于学习面向对象和设计模式很好帮助
- Linux 系统开机启动过程分析
- hdu 3265 Posters
- flex显示sprite
- vc 显示CWnd窗口Resizing范围
- Vc++调试技巧之调用堆栈
- Linux--7:vi命令
- spoj 78
- 扫盲行动之九:Vi编辑器的基本使用方法!
- gcc 换了,gdb也得跟着换
- 光纤及光纤接口