题意:求三个矩形体积的并

链接:点我

枚举z

 #include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<map>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
#define maxn 1100
#define mem(a,b) (memset(a),b,sizeof(a))
#define lmin 1
#define rmax len
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define root lmin,rmax,1
#define now l,r,rt
#define int_now int l,int r,int rt
#define INF 99999999
#define LL long long
#define mod 10007
#define eps 1e-6
#define zero(x) (fabs(x)<eps?0:x)
#define LL __int64
map<int,int>mp;
int du[maxn*];
struct lines
{
int x;
int y,yy;
int z,zz;
int leap;
friend bool operator <(const lines &a,const lines &b)
{
return a.x<b.x;
}
} line[maxn*];
int num[maxn**];
int sum[maxn**];
int kum[maxn**];
int cover[maxn**];
void push_down(int_now)
{ }
void push_up(int_now)
{
int len=du[r+]-du[l];
if(cover[rt]==)
{
num[rt]=num[rt<<]+num[rt<<|];
sum[rt]=sum[rt<<]+sum[rt<<|];
kum[rt]=kum[rt<<]+kum[rt<<|];
}
if(cover[rt]==)
{
num[rt]=len;
sum[rt]=num[rt<<]+num[rt<<|];
kum[rt]=sum[rt<<]+sum[rt<<|];
}
if(cover[rt]==)
{
num[rt]=len;
sum[rt]=len;
kum[rt]=num[rt<<]+num[rt<<|];
}
if(cover[rt]>=)
{
num[rt]=len;
sum[rt]=len;
kum[rt]=len;
}
}
void creat()
{
memset(cover,,sizeof(cover));
memset(num,,sizeof(num));
memset(sum,,sizeof(sum));
memset(kum,,sizeof(kum));
}
void updata(int ll,int rr,int x,int_now)
{
if(ll>r||rr<l)return;
if(ll<=l&&rr>=r)
{
cover[rt]+=x;
push_up(now);
return;
}
updata(ll,rr,x,lson);
updata(ll,rr,x,rson);
push_up(now);
}
int main()
{
int T,cas;
scanf("%d",&T);
cas=;
while(T--)
{
cas++;
int n,x,y,z,xx,yy,zz;
mp.clear();
scanf("%d",&n);
LL ls=;
du[]=-;
for(int i=; i<=n; i++)
{
scanf("%d%d%d%d%d%d",&x,&y,&z,&xx,&yy,&zz);
line[i*-].x=x;
line[i*-].y=y;
line[i*-].yy=yy;
line[i*-].z=z;
line[i*-].zz=zz;
line[i*-].leap=;
line[i*].x=xx;
line[i*].y=y;
line[i*].yy=yy;
line[i*].z=z;
line[i*].zz=zz;
line[i*].leap=-;
du[ls++]=y;
du[ls++]=yy;
}
sort(line+,line+n*+);
sort(du+,du+ls);
int len=;
for(int i=; i<ls; i++)
{
if(du[i]!=du[i-])
{
mp[du[i]]=len;
du[len++]=du[i];
}
}
len-=;
LL are=;
int st=;
creat();
for(int j=-; j<; j++)
{
st=;
for(int i=; i<=n*; i++)
{
int l,r;
l=mp[line[i].y];
r=mp[line[i].yy];
if(line[i].z>j||line[i].zz<=j)continue;
LL x,y;
x=(LL)kum[];
y=(LL)line[i].x-st;
are+=x*y;
updata(l,r-,line[i].leap,root);
st=line[i].x;
}
}
printf("Case %d: %I64d\n",cas,are);
}
return ;
}

hdu 3642 体积并的更多相关文章

  1. hdu 3642 Get The Treasury(扫描线)

    pid=3642" style="">题目链接:hdu 3642 Get The Treasury 题目大意:三维坐标系,给定若干的长方体,问说有多少位置被覆盖3次 ...

  2. HDU 3642 扫描线(立方体体积并)

    Get The Treasury Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  3. Get The Treasury HDU - 3642(体积扫描线)

    给出n个立方体,要你求这些立方体至少被覆盖三次的部分. 先把这个立方体的信息存在来,发现Z的范围不大,z范围是是[-500,500],所以我们可以先离散化,然后枚举Z, 然后对于每一段Z的区域内,在当 ...

  4. hdu 3642 覆盖3次以上体积

    http://www.cnblogs.com/kane0526/archive/2013/03/06/2947118.html 题目大意:给你n个立方体,求相交区域大于等于三次的体积和. 这题需要前面 ...

  5. HDU 3642 Get The Treasury ( 线段树 求长方体体积并 )

    求覆盖三次及其以上的长方体体积并. 这题跟 http://wenku.baidu.com/view/d6f309eb81c758f5f61f6722.html 这里讲的长方体体积并并不一样. 因为本题 ...

  6. Get The Treasury HDU - 3642(扫描线求三维面积交。。体积交)

    题意: ...就是求体积交... 解析: 把每一层z抽出来,计算面积交, 然后加起来即可..! 去看一下 二维面积交的代码 再看看这个三维面积交的代码.. down函数里 你发现了什么规律!!! 参考 ...

  7. HDU 3642 - Get The Treasury - [加强版扫描线+线段树]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3642 Time Limit: 10000/5000 MS (Java/Others) Memory L ...

  8. HDU 3642 求体积交集

    Get The Treasury 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=3642 Problem Description Jack knows ...

  9. hdu 3642 Get The Treasury

    Get The Treasury http://acm.hdu.edu.cn/showproblem.php?pid=3642 Time Limit: 10000/5000 MS (Java/Othe ...

随机推荐

  1. C.Fountains(Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2)+线段树+RMQ)

    题目链接:http://codeforces.com/contest/799/problem/C 题目: 题意: 给你n种喷泉的价格和漂亮值,这n种喷泉题目指定用钻石或现金支付(分别用D和C表示),C ...

  2. Distance Gym - 102028I (思维)

    题目链接:https://cn.vjudge.net/problem/Gym-102028I 具体思路:首先我们选定左边界和右边界.然后每一次按照左边一个,第二次右边一个的规律往上就可以了 具体原因: ...

  3. python并发编程之gevent协程(四)

    协程的含义就不再提,在py2和py3的早期版本中,python协程的主流实现方法是使用gevent模块.由于协程对于操作系统是无感知的,所以其切换需要程序员自己去完成. 系列文章 python并发编程 ...

  4. python并发编程之multiprocessing进程(二)

    python的multiprocessing模块是用来创建多进程的,下面对multiprocessing总结一下使用记录. 系列文章 python并发编程之threading线程(一) python并 ...

  5. C/C++——库函数strcpy和strdup比较

    版权声明:原创文章,禁止转载. 1. strcpy 原型: extern char *strcpy(char *dest,char *src); 用法: #include <string.h&g ...

  6. ActiveMQ-Prefetch机制和constantPendingMessageLimitStrategy

    首先简要介绍一下prefetch机制.ActiveMQ通过prefetch机制来提高性能,这意味这 客户端的内存里可能会缓存一定数量的消息.缓存消息的数量由prefetch limit来控 制.当某个 ...

  7. python使用virtualenv

    virtualenv是python的虚拟环境,可以同时存在多个不同的虚拟环境. #1.安装virtualenv pip install virtualenv #2.创建目录 mkdir myproje ...

  8. Integer类实现方式和注意事项

    java.lang.Integer类的源代码: //定义一个长度为256的Integer数组 static final Integer[] cache = new Integer[-(-128) + ...

  9. BeanUtils简化数据封装

    BeanUtils主要用来封装JavaBean的. 1.什么是JavaBean JavaBean指的是标准的类. 要求: 1. 类必须被public修饰2. 必须提供空参的构造器3. 成员变量必须使用 ...

  10. 语音性别识别 - 使用R提取特征

    步骤 1)安装R.windows操作系统安装包的链接:https://cran.r-project.org/bin/windows/base/ 2)切换当前路径为脚本所在路径 点击 文件 > 改 ...