http://blog.csdn.net/firenet1/article/details/47041145

#include <iostream>
#include <algorithm>
#include <string.h>
#include <cmath>
#include <cstdio>
#include <set>
using namespace std;
const int maxn=;
struct Circle
{
int id,x,y,r;
Circle(int cid=,int cx=,int cy=,int cr=)
{
id=cid; x=cx; y=cy; r=cr;
}
}cir[maxn],P[maxn]; bool cmp(Circle a, Circle b)
{
return a.x<b.x;
}
int globalx;
struct point{
int id,ty;
point(int cid=, int cty=){
id=cid;
ty=cty;
}
};
double yposition(int id, int ty)
{
double x=globalx-cir[id].x;
double y=sqrt(1.0*cir[id].r*cir[id].r-x*x);
if(ty==)return cir[id].y+y;
return cir[id].y-y;
}
bool operator <(point a, point b)
{
if(a.id==b.id)return a.ty>b.ty;
return yposition(a.id,a.ty)>yposition(b.id,b.ty);
}
bool operator == (point a, point b)
{
return a.id==b.id&&a.ty==b.ty;
} set<point>Q;
int dep[maxn];
int main()
{
int n;
while(scanf("%d",&n)==)
{
Q.clear();
int cnt=;
for(int i=; i<n; i++)
{
scanf("%d%d%d",&cir[i].x,&cir[i].y, &cir[i].r);
cir[i].id=i;
P[cnt++]=Circle(i,cir[i].x-cir[i].r,);
P[cnt++]=Circle(i,cir[i].x+cir[i].r,);
}
sort(P,P+cnt,cmp);
memset(dep,,sizeof(dep));
set<point>:: iterator it1,it2;
int ans=;
for(int i=; i<cnt; i++)
{
globalx=P[i].x;
if(P[i].y==)
{
Q.erase(point(P[i].id,));
Q.erase(point(P[i].id,));
}else
{
it1=Q.insert(point(P[i].id,)).first;
it2=it1;
it1++;
if(it1==Q.end()||it2==Q.begin()){
dep[ P[i].id] =;
}else
{
it2--;
if(it1->id==it2->id){
dep[P[i].id]=dep[it1->id]+;
}else
{
dep[P[i].id]=max(dep[it1->id],dep[it2->id]);
}
} Q.insert(point(P[i].id,)); }
ans=max(dep[P[i].id],ans);
}
printf("%d\n",ans);
}
return ;
}

hdu3511 圆的扫描线的更多相关文章

  1. hdu3511 Prison Break 圆的扫描线

    地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=3511 题目: Prison Break Time Limit: 10000/5000 MS ( ...

  2. HDU5299 圆的扫描线 && 树上删边博弈

    HDU5299 圆的扫描线 && 树上删边博弈 标签(空格分隔): 未分类 给出若干个圆,可以互相嵌套但不相交或相切. 每次删去一个圆和它内部的圆,进行博弈,问谁赢. 分成两部分.首先 ...

  3. bzoj4561: [JLoi2016]圆的异或并 圆的扫描线

    地址:http://www.lydsy.com/JudgeOnline/problem.php?id=4561 题目: 4561: [JLoi2016]圆的异或并 Time Limit: 30 Sec ...

  4. POJ - 1981 :Circle and Points (圆的扫描线) hihocoder1508

    题意:给定N个点,然后给定一个半径为R的圆,问这个圆最多覆盖多少个点. 思路:在圆弧上求扫描线. 如果N比较小,不难想到N^3的算法. 一般这种覆盖问题你可以假设有两个点在圆的边界上,那么每次产生的圆 ...

  5. 【LOJ2586】【APIO2018】选圆圈 CDQ分治 扫描线 平衡树

    题目描述 在平面上,有 \(n\) 个圆,记为 \(c_1,c_2,\ldots,c_n\) .我们尝试对这些圆运行这个算法: 找到这些圆中半径最大的.如果有多个半径最大的圆,选择编号最小的.记为 \ ...

  6. 计算几何值平面扫面poj2932 Coneology

    Coneology Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 4097   Accepted: 859 Descript ...

  7. Coneology(POJ 2932)

    原题如下: Coneology Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 4937   Accepted: 1086 D ...

  8. 【APIO2018】选圆圈(平面分块 | CDQ分治 | KDT)

    Description 给定平面上的 \(n\) 个圆,用三个参数 \((x, y, R)\) 表示圆心坐标和半径. 每次选取最大的一个尚未被删除的圆删除,并同时删除所有与其相切或相交的圆. 最后输出 ...

  9. 洛谷P3268 [JLOI2016]圆的异或并(扫描线)

    扫描线还不是很熟啊--不管是从想的方面还是代码实现的方面-- 关于这题,考虑一条平行于\(y\)轴的扫描线从左到右扫描每一个圆,因为只有相离和内含两种关系,只用在切线处扫描即可 我们设上半圆为1,下半 ...

随机推荐

  1. LeetCode 973 K Closest Points to Origin 解题报告

    题目要求 We have a list of points on the plane.  Find the K closest points to the origin (0, 0). (Here, ...

  2. 2018/09/17《涂抹MySQL》【性能优化及诊断】学习笔记(七)

    读 第十三章<MySQL的性能优化与诊断> 总结 一说性能优化,整个人都像被打了鸡血一样

  3. Appium入门(3)__ Appium Server安装

    安装Appium 1.下载并安装:https://bitbucket.org/appium/appium.app/downloads/ 2. 系统变量PATH 增加 C:\Program Files ...

  4. python之if __name__ == '__main__'

    if __name__ == '__main__' 我们简单的理解就是: 如果模块是被直接运行的,则代码块被运行,如果模块是被导入的,则代码块不被运行.

  5. 洛谷P2303 [SDOi2012] Longge的问题 数论

    看懂了题解,太妙了TT但是想解释的话可能要很多数学公式打起来太麻烦了TT所以我就先只放代码具体推演的过程我先写在纸上然后拍下来做成图片放上来算辣quq 好的那我先滚去做题了做完这题就把题解放上来.因为 ...

  6. Intellij IDEA中修改Maven项目的项目名称

    1. 原项目名:votesystem-redis     想要重命名成新项目名:votesystem 2. 我们对此项目名进行Rename 3. 再对此项目所在的目录下进行修改 4. 重新打开项目 若 ...

  7. Cookie和Session的区别?

    1.Cookie和Session都是会话技术,Cookie是运行在客户端,Session是运行在服务器端.      2.Cookie有大小限制以及浏览器在存cookie的个数也有限制,Session ...

  8. 数据库机器迁移对AlwaysON 集群影响测试

    1主3从(共享文件见证)     模拟事故 AlwaysON集群 结论 主域控服务器重启 共享文件夹见证失败,SQL集群无影响 无影响 修改共享文件夹见证路径 第一次测试修改后:整个集群突然重启,查询 ...

  9. H5-FileReader实现图片预览&Ajax上传文件

    图片预览 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF- ...

  10. 构造器初始化(static)

    package demo; /* * 在类 的内部,变量定义的先后顺序决定了初始化的顺序.即使变量定义散布于方法定义之间, * 它们仍旧会在任何方法(包括构造器)被调用之前得到初始化. */ publ ...