这题,简直丧心病狂了。

大意是给你一个环上一些覆盖的区间,让你求总覆盖长度。

非常坑的点是这个区间因为是个环,所以可能逆时针给你,也可能顺时针给你,你特别要注意。那么区分顺时针和逆时针的方法

就是,题目中的一句关键:每个区间都小于180.根据这个判断就可以。还有一个要注意的地方就是,他可能在一个角度中的不能分度搞你。这题我是彻底服了。把我坑的底朝天。后来管理BZOJ要的数据才明白是怎么回事。。。。太弱弱了。。。。

Code:

 #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream> using namespace std; int N;
int pos = ,Ans = ,tot = ; struct data{
int flag;
int sum;
}w[]; int q[];
int tail = ;
bool cmp(data a,data b);
int main(){
scanf("%d",&N);
for(int i = ;i <= N;++ i){
int x1,y1,z1,x2,y2,z2;
scanf("%d%d%d%d%d%d",&x1,&y1,&z1,&x2,&y2,&z2);
if(x1 > x2){//so silly..caocao
if(x1 - x2 >= ){
++ tot;
w[tot].sum = x1*+y1*+z1;
w[tot].flag = ;
++ tot;
w[tot].sum = *;
w[tot].flag = ;
++ tot;
w[tot].sum = ;
w[tot].flag = ;
++ tot;
w[tot].sum = x2*+y2*+z2;
w[tot].flag = ;
}
else{
++ tot;
w[tot].sum = x2*+y2*+z2;
w[tot].flag = ;
++ tot;
w[tot].sum = x1*+y1*+z1;
w[tot].flag = ;
}
}
else if(x2 > x1){
if(x2 - x1 >= ){
++ tot;
w[tot].sum = x2*+y2*+z2;
w[tot].flag = ;
++ tot;
w[tot].sum = *;
w[tot].flag = ;
++ tot;
w[tot].sum = ;
w[tot].flag = ;
++ tot;
w[tot].sum = x1*+y1*+z1;
w[tot].flag = ;
}
else{
++ tot;
w[tot].sum = x1*+y1*+z1;
w[tot].flag = ;
++ tot;
w[tot].sum = x2*+y2*+z2;
w[tot].flag = ;
}
}
else if(x2 == x1){
if(y2 == y1){
if(z1 > z2){
++ tot;
w[tot].sum = x1*+y2*+z2;
w[tot].flag = ;
++ tot;
w[tot].sum = x1*+y2*+z1;
w[tot].flag = ;
}
else{
++ tot;
w[tot].sum = x1*+y2*+z1;
w[tot].flag = ;
++ tot;
w[tot].sum = x1*+y2*+z2;
w[tot].flag = ;
}
}
else{
if(y1 > y2){
++ tot;
w[tot].sum = x1*+y2*+z2;
w[tot].flag = ;
++ tot;
w[tot].sum = x2*+y1*+z1;
w[tot].flag = ;
}
else{
++ tot;
w[tot].sum = x1*+y1*+z1;
w[tot].flag = ;
++ tot;
w[tot].sum = x2*+y2*+z2;
w[tot].flag = ;
} }
}
}
sort(w+,w+tot+,cmp); while(true){
++ pos;
if(pos > tot)
break;
if(w[pos].flag == ){
q[++ tail] = w[pos].sum;
}
else if(w[pos].flag == ){
if(tail == ){
Ans += w[pos].sum - q[tail];
-- tail;
}
else
-- tail;
}
}
printf("%d",Ans);
return ;
} bool cmp(data a,data b){
return a.sum < b.sum;
}

Have a Look

BZOJ 3368 约翰看山(扫描)O(N)的更多相关文章

  1. TTTTTTTTTTTTTTTTTT Gym 100851L 看山填木块

    题意:这题是给你w列方格,然后给你n个方块,让你加进去,使得这个图变得最高,加的要求是,如果这块的下面,以及左下右下都有,才能放 #include <cstdio> #include &l ...

  2. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  3. 自定义ZXing二维码扫描界面并解决取景框拉伸等问题

    先看效果 扫描内容是下面这张,二维码是用zxing库生成的 由于改了好几个类,还是去年的事都忘得差不多了,所以只能上这个类的代码了,主要就是改了这个CaptureActivity.java packa ...

  4. BZOJ.5319.[JSOI2018]军训列队(主席树)

    LOJ BZOJ 洛谷 看错了,果然不是\(ZJOI\)..\(jry\)给\(JSOI\)出这么水的题做T3么= = 感觉说的有点乱,不要看我写的惹=-= 对于询问\(l,r,k\),设\(t=r- ...

  5. spring启动component-scan类扫描加载过程(转)

    文章转自 http://www.it165.net/pro/html/201406/15205.html 有朋友最近问到了 spring 加载类的过程,尤其是基于 annotation 注解的加载过程 ...

  6. 【Spring源码分析系列】启动component-scan类扫描加载过程

    原文地址:http://blog.csdn.net/xieyuooo/article/details/9089441/ 在spring 3.0以上大家都一般会配置一个Servelet,如下所示: &l ...

  7. 冰雪奇缘,白色世界:四个IT人的四姑娘山双桥沟游记

    去年9月初去了川西的稻城亚丁,体会了金色世界秋日童话,还写了一篇游记<从你的全世界路过-一群程序员的稻城亚丁游记>,也是得到了很多朋友和童鞋的点赞.今年11月初趁着周末的两天时间和朋友去了 ...

  8. BZOJ 3238 差异

    BZOJ 3238 差异 看这个式子其实就是求任意两个后缀的 $ LCP $ 长度和.前面的 $ len(T_i)+len(T_j) $ 求和其实就是 $ n(n-1)(n+1)/2 $ ,这个是很好 ...

  9. 3000本IT书籍下载地址

    http://www.shouce.ren/post/d/id/112300    黑客攻防实战入门与提高.pdfhttp://www.shouce.ren/post/d/id/112299    黑 ...

随机推荐

  1. SPOJ 4110 Fast Maximum Flow (最大流模板)

    题目大意: 无向图,求最大流. 算法讨论: Dinic可过.终于我的常数还是太大.以后要注意下了. #include <cstdio> #include <cstring> # ...

  2. uvA Flooded!

    Description To enable homebuyers to estimate the cost of flood insurance, a real-estate firm provide ...

  3. 显示查询记录的前n条 mysql limit用法

    按时间倒序出所有的数据 mysql order by createtime desc ; +----+------------------+ | id | id_no | +----+-------- ...

  4. JS的全局变量&局部变量

    <script> var i=10; //全局变量 j = 20; //全局变量 function(){ var i=30; //局部变量 h = 40; //全局变量 } </sc ...

  5. css元素隐藏(display:none和visibility:hidden)

    在css中, display:none和visibility:hidden都能够使元素隐藏.但是两者所带来的效果完全不同. css  display:none 当使用该样式的时候,HTML元素的宽高等 ...

  6. opencv学习之旅_绘制跟踪轨迹

    如何将运动物体的轨迹画出来 我的想法是先:用CAMSHIFT跟踪物体,这个函数会返回一个track_box,将box的中心提取出来,然后以这个中心在另外的图像上画出来,然后将这张图像处理,提取轮廓,提 ...

  7. 手机三种SIM卡 你所不知道的剪卡“秘密”

    SIM卡物理尺寸的发展是逐渐轻薄化,尺寸逐渐缩小的一个过程,最早手机中的卡都是2FF,2003年国际标准提出3FF,当前很多终端都使用这种形态的卡,4FF在2011年的国际标准会议中提出,2012年纳 ...

  8. DES、AES、TEA加密算法的比较

    1.     DES算法介绍: DES算法具有对称性, 既可以用于加密又可以用于解密.对称性带来的一个很大的好处在于硬件实现, DES 的加密和解密可以用完全相同的硬件来实现.DES 算法的明文分组是 ...

  9. 找不到Qt5Cored.dll(Release和Debug版连接了不同的库)

    Qt5Cored.dll和Qt5Core.dll文件分别用于Qt软件的Debug版和Release版. 通常会有两个Qt5Core.dll文件,分别位于Qti安装目录下的“Qt5.1.0\5.1.0\ ...

  10. Delphi中动态创建的Panel无法改变颜色的解决办法(要把Panel的ParentBackground设为False)

    刚开始代码如下: procedure TForm1.Button1Click(Sender: TObject); var Panel: TPanel; begin Panel := TPanel.Cr ...