链接

刚开始看n挺小,以为是二维的线段树,想了一会也没想到怎么解,之后看到z值非常小,想到可以直接枚举z,确定一个坐标,然后把三维转化为二维,把体积转化为面。

枚举z从-500到500,然后用面积并的解法求出单位z坐标上满足题意的面积。

把1写成了L,查错查了好久。其余还好,1A。

求覆盖超过两次的面积,up更新上的写法如下:

void up(int w,int l,int r)
{
if(fs[w]>)
{
s[w][] = s[w][] = s[w][] = val[r+] - val[l];
}
else if(fs[w]>)
{
s[w][] = s[w][] = val[r+]-val[l];
if(l==r)
s[w][] = ;
else s[w][] = s[w<<][]+s[w<<|][];
}
else if(fs[w])
{
s[w][] = val[r+]-val[l];
if(l==r)
s[w][] = s[w][] = ;
else
{
s[w][] = s[w<<][]+s[w<<|][];
s[w][] =s[w<<][]+s[w<<|][];
}
}
else
{
if(l==r)
s[w][] = s[w][] = s[w][] = ;
else
{
s[w][] = s[w<<][]+s[w<<|][];
s[w][] = s[w<<][]+s[w<<|][];
s[w][] = s[w<<][]+s[w<<|][];
}
}
}

代码:

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define N 2010
#define LL __int64
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
map<int,int>f;
struct node
{
int x1,x2,y,f;
int z1,z2;
node(){}
node(int x1,int x2,int y,int f,int z1,int z2):x1(x1),x2(x2),y(y),f(f),z1(z1),z2(z2){}
bool operator < (const node &S) const
{
return y<S.y;
}
}p[N],q[N];
int a[N],val[N];
int s[N<<][],fs[N<<];
void up(int w,int l,int r)
{
if(fs[w]>)
{
s[w][] = s[w][] = s[w][] = val[r+] - val[l];
}
else if(fs[w]>)
{
s[w][] = s[w][] = val[r+]-val[l];
if(l==r)
s[w][] = ;
else s[w][] = s[w<<][]+s[w<<|][];
}
else if(fs[w])
{
s[w][] = val[r+]-val[l];
if(l==r)
s[w][] = s[w][] = ;
else
{
s[w][] = s[w<<][]+s[w<<|][];
s[w][] =s[w<<][]+s[w<<|][];
}
}
else
{
if(l==r)
s[w][] = s[w][] = s[w][] = ;
else
{
s[w][] = s[w<<][]+s[w<<|][];
s[w][] = s[w<<][]+s[w<<|][];
s[w][] = s[w<<][]+s[w<<|][];
}
}
}
void build(int l,int r,int w)
{
s[w][] = s[w][] = s[w][] = ;
fs[w] = ;
if(l==r)
return ;
int m = (l+r)>>;
build(l,m,w<<);
build(m+,r,w<<|);
up(w,l,r);
}
void update(int a,int b,int d,int l,int r,int w)
{
// cout<<l<<" "<<r<<" "<<w<<endl;
if(a<=l&&b>=r)
{
fs[w]+=d;
//cout<<l<<" "<<r<<" "<<fs[w]<<" "<<w<<endl;
up(w,l,r);
return ;
}
int m = (l+r)>>;
if(a<=m) update(a,b,d,l,m,w<<);
if(b>m) update(a,b,d,m+,r,w<<|);
up(w,l,r);
}
int main()
{
int n,i,j;
int t,kk=;
cin>>t;
while(t--)
{
scanf("%d",&n);
f.clear();
int g = ;
for(i = ;i <= n; i++)
{
int x1,x2,y1,y2,z1,z2;
scanf("%d%d%d%d%d%d",&x1,&y1,&z1,&x2,&y2,&z2);
p[++g] = node(x1,x2,y1,,z1,z2);
a[g] = x1;
p[++g] = node(x1,x2,y2,-,z1,z2);
a[g] = x2;
}
sort(a+,a+g+);
sort(p+,p+g+);
int o = ;
f[a[]] = ++o;
val[] = a[];
for(i = ; i <= g; i++)
if(a[i]!=a[i-])
{
f[a[i]] = ++o;
val[o] = a[i];
}
LL ans = ;
for(i = - ; i < ; i++)
{
int e = ;
build(,o-,);
for(j = ; j <= g ;j++)
{
if(p[j].z1>i||p[j].z1>i+||i>p[j].z2||p[j].z2<i+)
continue;
q[++e] = p[j];
}
for(j = ; j < e; j++)
{
int l = f[q[j].x1];
int r = f[q[j].x2]-;
// cout<<q[i].f<<" "<<i<<endl;
if(l<=r)
{
update(l,r,q[j].f,,o-,);
}
LL sum = (LL)(q[j+].y-q[j].y)*s[][];
//cout<<sum<<" ."<<i<<" "<<s[1][2]<<endl;
ans+=sum;
}
}
printf("Case %d: %I64d\n",++kk,ans);
}
return ;
}

hdu3642Get The Treasury的更多相关文章

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

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

  2. hdu 3642 Get The Treasury

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

  3. hdu3642 Get The Treasury 线段树--扫描线

    Jack knows that there is a great underground treasury in a secret region. And he has a special devic ...

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

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

  5. luogu P1623 [CEOI2007]树的匹配Treasury

    题目链接 luogu P1623 [CEOI2007]树的匹配Treasury 题解 f[i][0/1]表示当前位置没用/用了 转移暴力就可以了 code // luogu-judger-enable ...

  6. HDU3642 Get The Treasury —— 求矩形交体积 线段树 + 扫描线 + 离散化

    题目链接:https://vjudge.net/problem/HDU-3642 Jack knows that there is a great underground treasury in a ...

  7. HDU 3642 Get The Treasury (线段树扫描线)

    题意:给你一些长方体,问你覆盖三次及以上的体积有多大 首先我们观察x轴y轴一样很大,但是z轴很小,所以我们可以枚举z轴(-500,500),注意我们枚举的是每一段长度为一的z轴的xy轴的面积而不是点. ...

  8. HDU 3642 Get The Treasury (线段树扫描线,求体积并)

    参考链接 : http://blog.csdn.net/zxy_snow/article/details/6870127 题意:给你n个立方体,求覆盖三次以上(包括三次)的区域的体积 思路:先将z坐标 ...

  9. HDU 3642 Get The Treasury 线段树+分层扫描线

    http://www.acmerblog.com/hdu-3642-get-the-treasury-6603.html 学习:三维就是把竖坐标离散化分层,每一层进行线段树二维面积并就好了

随机推荐

  1. js获取浏览器宽高、网页宽高、屏幕宽高、鼠标位置等(带图片说明)

    网页可见区域宽: document.body.clientWidth;网页可见区域高: document.body.clientHeight;(点击查看大图) 网页可见区域宽: document.bo ...

  2. 「NOIP2002」「Codevs1099」 字串变换(BFS

    1099 字串变换 2002年NOIP全国联赛提高组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold   题目描述 Description 已知有两个字串 $A$, ...

  3. VirtualBox下安装ubuntu图文教程以及软件安装

    一. 下载安装VirtualBox 官网下载VirtualBox,目前版本:VirtualBox 5.1.8 for Windows hosts x86/amd64 下载好了安装VirtualBox, ...

  4. bzoj 3745 [Coci2015]Norma——序列分治

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3745 如果分治,就能在本层仅算过 mid 的区间了. 可以从中间到左边地遍历左边,给右边两个 ...

  5. bzoj4006

    斯坦纳树 比之前要求高了一些 其实利用斯坦纳树的dp[i][s]以i为根,S为状态就行了,先跑一遍斯坦纳树,预处理出dp数组,记住每个S的最小值,然后再dp,这里dp必须要求同一种颜色的状态都必须在S ...

  6. elmo驱动器使用EAS II配置教程

    一.驱动器接线 1.1驱动器接口: 驱动器接线,需要连接两个接口,一个是反馈接口,一个是STO接口. 反馈接口,我这里使用了elmo驱动器的Port A.这个接口提供5v电源.并且可以输入旋转编码器和 ...

  7. 使用Swing组件实现简单的进制转换

    请编写图像界面程序, 用户在第一文本行输入数字, 有三个按钮,分别是计算2进制,8进制,16进制, 点击其中一个按钮,第一个文本行中的数据转换为相应进制的数显示在第二个文本行中. import jav ...

  8. error: declaration of 'cv::Mat R ' shadows a parameter

    变量被覆盖. 例: void pose_estimation_2d2d::_pose_estimation_2d2d(const vector<KeyPoint> &v_keypo ...

  9. c/c++时间相关

    本文从介绍基础概念入手,探讨了在C/C++中对日期和时间操作所用到的数据结构和函数,并对计时.时间的获取.时间的计算和显示格式等方面进行了阐述.本文还通过大量的实例向你展示了time.h头文件中声明的 ...

  10. Flutter实战视频-移动电商-27.列表页_现有Bug修复和完善

    27.列表页_现有Bug修复和完善 小解决小bug 默认右侧的小类没有被加载 数据加载完成后,就list的第一个子对象传递给provide进行赋值,这样右侧的小类就刷新了数据 默认加载了第一个类别 调 ...