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

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

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

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

这说明我们可以二分了:每条线段两端砍掉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. 今年plan,做好四件事情

    写代码, 写博客, 学英语, 锻炼身体.

  2. iOS 端的 UI 聊天组件ChatKit及代码实现

    ChatKit 是一个免费且开源的 UI 聊天组件,自带云服务器,自带推送,支持消息漫游,消息永久存储.底层聊天服务基于LeanCloud(原名 AVOS ) 的 IM 实时通信服务「LeanMess ...

  3. Oracle GoldenGate 12c实时捕获SQL Server数据

    在Oracle GoldenGate 12c中,对一些最新的数据库提供了支持,比如SQL Server 2012/2014,当然12c也支持sql server 2008.主要新增特性有: 捕获进程可 ...

  4. Git ~ 大杀器之一 远程仓库 ~ Git

    一般情况ixashi找一台电脑作为服务器的角色 , 每天24小时开机 , 其他扥每个人都从这个 “服务器” 仓库里面克隆一份到自己的电脑上面 并且将各自的提交推送到服务器仓库中 , 也可以从服务器仓库 ...

  5. python构建模拟模型——网站独立访问用户数量

    背景:发现一个有趣的现象,即一些用户在每一月都仅仅访问网站一次,我们想要了解这些人数量的变化趋势. 建立数学模型:简化问题,根据瓮模型推导出公式(具体推导见<数据之魅>,有时间再补充... ...

  6. XAMPP Apache 配置多端口和多域名方法

    我们在工作中经常遇到同时调试多个网站的情况,那么如何配置呢?就像平时访问网站一样,网站 a.com 与网站 b.com 截然不同.这都是常见现象,如果在局域网中要访问另外一台电脑上的多个网站,就需要使 ...

  7. Cocos2d-x 2.x项目创建

    cocos2d-x下载地址:http://www.cocos2d-x.org/download 2.0之后的创建项目 1. cd cocos2d-x-2.2.1/tools/project-creat ...

  8. Unity3D ShaderLab法线贴图

    Unity3D ShaderLab法线贴图 说到法线贴图,应该算是我们最常使用的一种增强视觉效果的贴图.将法线贴图的各个像素点座位模型的法线,这样我们的光照可以模拟出高分辨率的效果, 同时也保持较低的 ...

  9. MySQL 基本函数

    (1).字符串类 CHARSET(str) //返回字串字符集 CONCAT (string2 [,... ]) //连接字串 INSTR (string ,substring ) //返回subst ...

  10. HDU 5045

    http://acm.hdu.edu.cn/showproblem.php?pid=5045 题意:n个学生m道题,一个n*m的矩阵代表第n个学生解第m题AC的概率,任意两学生做题数差距不能大于1,问 ...