这题觉得似乎不难的样子……

但硬是没有做出来,真是不知说什么好喵~

注意到没有两条共线的线段具有公共点,没有重合的线段

说明每个十字形最多涉及一个水平线段和一个竖直线段

这说明我们可以二分了:每条线段两端砍掉delta长度后,有没有线段有公共点?

很水的扫描线吧~  按 X 轴扫描,先把横的线段扫进去,再用竖的线段去查询

但是写法是很重要的,我说我不用线段树你信喵?我说我连离散化都不用你信喵?

约大爷教你做人!@Ruchiose
 
 #include <cstdio>
#include <algorithm>
#include <set>
const int size=; namespace IOspace
{
inline int getint()
{
register int num=;
register char ch=, last;
do last=ch, ch=getchar(); while (ch<'' || ch>'');
do num=num*+ch-'', ch=getchar(); while (ch>='' && ch<='');
if (last=='-') num=-num;
return num;
}
inline void putint(int num, char ch='\n')
{
char stack[];
register int top=;
if (num==) stack[top=]='';
for ( ;num;num/=) stack[++top]=num%+'';
for ( ;top;top--) putchar(stack[top]);
if (ch) putchar(ch);
}
} struct line
{
int x, y, l;
inline line() {}
inline line(int _x, int _y, int _l):x(_x), y(_y), l(_l) {}
};
struct node
{
int type;
int x, y1, y2;
inline node() {}
inline node(int _type, int _x, int _y1, int _y2):type(_type), x(_x), y1(_y1), y2(_y2) {}
inline bool operator < (node a) const {return x!=a.x?x<a.x:type*y2>a.type*a.y2;}
}; int n, m, k;
line h[size], s[size];
node q[size];
std::multiset<int> t;
inline int max(int x, int y) {return x>y?x:y;}
inline void swap(int & a, int & b) {int t=a; a=b; b=t;}
inline bool query(int, int);
inline bool check(int); int main()
{
n=IOspace::getint(); m=IOspace::getint();
for (int i=;i<n;i++) s[i].x=IOspace::getint(), s[i].y=IOspace::getint(), s[i].l=IOspace::getint();
for (int i=;i<m;i++) h[i].x=IOspace::getint(), h[i].y=IOspace::getint(), h[i].l=IOspace::getint(); int left=, right=, mid;
for (int i=;i<n;i++) right=max(right, s[i].l);
while (left+<right)
{
mid=(left+right)>>;
if (check(mid)) left=mid;
else right=mid;
} IOspace::putint(left); return ;
} inline bool query(int l, int r)
{
return t.lower_bound(l)!=t.upper_bound(r);
}
inline bool check(int d)
{
k=;
for (int i=;i<m;i++) if (h[i].l>=(d<<))
{
q[k++]=node(, h[i].x+d, h[i].y, );
q[k++]=node(, h[i].x+h[i].l-d, h[i].y, -);
}
for (int i=;i<n;i++) if (s[i].l>=(d<<))
q[k++]=node(, s[i].x, s[i].y+d, s[i].y+s[i].l-d);
std::sort(q, q+k);
t.clear();
for (int i=;i<k;i++)
{
if (q[i].type)
{
if (q[i].y2==) t.insert(q[i].y1);
else t.erase(t.find(q[i].y1));
}
else
if (query(q[i].y1, q[i].y2))
return true;
}
return false;
}

本傻受益匪浅系列

只存操作(包括插入、删除、询问)真是无比的高大上,跪跪跪

还有那鬼畜的查询写法

(set).lower_bound(l)!=(set).upper_bound(r)

可以查询 [l..r] 中是否有数存在,至于为什么这样是对的而不是别的样子了,大家在纸上画画就知道了吧

其实更好理解的是

当 (set).lower_bound(l)==(set).upper_bound(r) 时, [l..r] 中一定没有数

lower_bound是为了将 l 算入 [l..r] 中,upper_bound(r) 也是为了将 r 算入 [l..r] 中

真是跪跪跪跪跪跪跪跪

[codeforces 391D2]Supercollider的更多相关文章

  1. 【Codeforces Rockethon 2014】Solutions

    转载请注明出处:http://www.cnblogs.com/Delostik/p/3553114.html 目前已有[A B C D E] 例行吐槽:趴桌子上睡着了 [A. Genetic Engi ...

  2. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  3. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  4. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  5. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  6. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  7. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  8. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  9. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

随机推荐

  1. mybatis 参数问题

    load方法,往sql语句中传一个参数的那种,似乎parameterType并不是那么重要,不写其实都可以,而且sql语句中的比如username=#{A} 这里面的A可以随便写,只要传过来的是个St ...

  2. 2013年7月份第4周51Aspx源码发布详情

    大型企业通用管理ERP源码  2013-7-26 [VS2010]2013.7.4更新内容:1.修复决策模式-客户等级不能保存问题.2.修复企业知识库有报错问题.3.修复运营模式-人力资源分析模块-在 ...

  3. Image Generator (Image Builder)

    如果你想要下载一个预编译好的镜像文件,或者想要尝试整个编译过程,一个替代方案是使用镜像生成器(Image Generator)(以前被叫做Image Builder).这是一个预编译好的OpenWrt ...

  4. (转)JS中innerHTML,innerText,value

    原文:http://holysonll.blog.163.com/blog/static/21413909320134111054352/ JS中innerHTML,innerText,value 2 ...

  5. php 安装composer

    右击我的电脑 再属性 再高级 再环境变量 再系统变量里有个path 双击打开来 把你的PHP路径 加个分号再前面 添加进去就OK了 1.http://www.th7.cn/Program/php/20 ...

  6. 程序员是怎么炼成的---OC题集--练习答案与题目(3)

    1.init 2.initWithBytes:length:encoding: 3.initWithCharacters:length: 4.initWithCString:encoding: 5.i ...

  7. 11、C#基础整理(特殊集合和哈希表)

    特殊集合:队列.栈 一.栈Stack类:先进后出,没有索引 Stack ss = new Stack(); 1.增加数据:push :将元素推入集合 ss.Push(); ss.Push(); ss. ...

  8. 中级iOS开发面试题

    1:MVC的理解 MVC设计模式考虑三种对象:数据模型对象,视图对象和控制器对象. 数据模型:负责存储.定义.操作数据: 视图:展示数据给用户,和用户进行操作交互: 控制器:M与V的协调者,控制获取数 ...

  9. 《深入浅出Node.js》第1章 Node简介

    @by Ruth92(转载请注明出处) 第1章 Node简介 一.Node的起源 高性能Web服务器的要点:事件驱动.非阻塞I/O. 选择JavaScript的原因:高性能.符合事件驱动.没有历史包袱 ...

  10. 快速构建express项目

    构建node项目 github地址 https://github.com/haoyongliang/quickly-create-node-project.git 创建最基本的node项目 1.全局安 ...