Coneology
Time Limit: 5000MS   Memory Limit: 65536K
Total Submissions: 3574   Accepted: 680

Description

A student named Round Square loved to play with cones. He would arrange cones with different base radii arbitrarily on the floor and would admire the intrinsic beauty of the arrangement. The student even began theorizing about how some cones dominate other cones: a cone A dominates another cone B when cone B is completely within the cone A. Furthermore, he noted that there are some cones that not only dominate others, but are themselves dominated, thus creating complex domination relations. After studying the intricate relations of the cones in more depth, the student reached an important conclusion: there exist some cones, all-powerful cones, that have unique properties: an all-powerful cone is not dominated by any other cone. The student became so impressed by the mightiness of the all-powerful cones that he decided to worship these all-powerful cones.

Unfortunately, after having arranged a huge number of cones and having worked hard on developing this grandiose cone theory, the student become quite confused with all these cones, and he now fears that he might worship the wrong cones (what if there is an evil cone that tries to trick the student into worshiping it?). You need to help this student by finding the cones he should worship.

Input

The input le specifies an arrangement of the cones. There are in total N cones (1 ≤ N ≤ 40000). Cone i has radius and height equal to Ri, i = 1 … N. Each cone is hollow on the inside and has no base, so it can be placed over another cone with smaller radius. No two cones touch.

The first line of the input contains the integer N. The next N lines each contain three real numbers Ri, xi, yi separated by spaces, where (xi, yi) are the coordinates of the center of the base of cone i.

Output

The first line of the output le should contain the number of cones that the student should worship. The second line contains the indices of the cones that the student should worship in increasing order. Two consecutive numbers should be separated by a single space.

Sample Input

5
1 0 -2
3 0 3
10 0 0
1 0 1.5
10 50 50

Sample Output

2
3 5

Source

【思路】

扫描线

将一个园最左点与最右点看作事件,按从左向右的顺序扫描。

如果扫描到最左点则判断在其上方和下方且最近的圆的包含关系,当不被上下两圆包含时累计答案。

如果最右点则删除该圆。

用set组织数据以实现查找与删除的功能。

【代码】

 #include<set>
#include<map>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mp(a,b) make_pair(a,b)
#define FOR(a,b,c) for(int a=(b);a<=(c);a++)
#define pr pair<double,int>
using namespace std; const int N = +; double x[N],y[N],r[N];
pr l[N*]; int tot;
set<pr> S;
set<pr> ::iterator it;
int n,ans,vis[N]; bool inside(int a,int b) {
return (x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b])<=r[b]*r[b];
} int main() {
scanf("%d",&n);
FOR(i,,n) scanf("%lf%lf%lf",&r[i],&x[i],&y[i]);
FOR(i,,n) {
l[++tot]=mp(x[i]-r[i],i);
l[++tot]=mp(x[i]+r[i],i+n);
}
sort(l+,l+tot+);
FOR(i,,tot) {
int now=l[i].second;
if(now<=n) {
it=S.lower_bound(mp(y[now],now));
if(it!=S.end() && inside(now,it->second)) continue;
if(it!=S.begin() && inside(now,(--it)->second)) continue;
vis[now]=; ans++;
S.insert(mp(y[now],now));
}
else
S.erase(mp(y[now-n],now-n));
}
printf("%d\n",ans);
FOR(i,,n) if(vis[i]) printf("%d ",i);
return ;
}

poj 2932 Coneology(扫描线+set)的更多相关文章

  1. POJ 2932 圆扫描线

    求n个圆中没有被包含的圆.模仿扫描线从左往右扫,到左边界此时如有3个交点,则有3种情况,以此判定该圆是否被离它最近的圆包含,而交点和最近的圆可以用以y高度排序的Set来维护.因此每次到左边界插入该圆, ...

  2. POJ 2932 Coneology(扫描线)

    [题目链接] http://poj.org/problem?id=2932 [题目大意] 给出N个两两没有公共点的圆,求所有不包含于其它圆内部的圆 [题解] 我们计算出所有点在圆心所有y位置的x值, ...

  3. poj 2932 Coneology (扫描线)

    题意 平面上有N个两两不相交的圆,求全部最外层的,即不被其它圆包括的圆的个数并输出 思路 挑战程序竞赛P259页 代码 /* ************************************* ...

  4. POJ 2932 Coneology计算最外层圆个数

    平面上有n个两两没有公共点的圆,i号圆的圆心在(xi,yi),半径为ri,编号从1开始.求所有最外层的,即不包含于其他圆内部的圆.输出符合要求的圆的个数和编号.n<=40000. (注意此题无相 ...

  5. TTTTTTTTTTTTTTT poj 2932 Coneology 平面扫描+STL

    题目链接 题意:有n个圆,圆之间不存在相交关系,求有几个不被其他任何圆包含的圆,并输出圆的编号: #include <iostream> #include <cstdio> # ...

  6. Coneology(POJ 2932)

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

  7. POJ 1151 Atlantis (扫描线+线段树)

    题目链接:http://poj.org/problem?id=1151 题意是平面上给你n个矩形,让你求矩形的面积并. 首先学一下什么是扫描线:http://www.cnblogs.com/scau2 ...

  8. N - Picture - poj 1177(扫描线求周长)

    题意:求周长的,把矩形先进行融合后的周长,包括内周长 分析:刚看的时候感觉会跟棘手,让人无从下手,不过学过扫描线之后相信就很简单了吧(扫描线的模板- -),还是不说了,下面是一精确图,可以拿来调试数据 ...

  9. poj2932 Coneology (扫描线)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Coneology Time Limit: 5000MS   Memory Lim ...

随机推荐

  1. Codevs 3233 古道

    3233 古道 时间限制: 1 s 空间限制: 8000 KB 题目等级:**白银 Silver** [传送门](http://codevs.cn/problem/3233/) 题目描述 Descri ...

  2. PDF编译出现错误解决办法

    今天在编译PDF时发现使用了一下STL中的z数值极限<Numeric Limits>竟然编译不过, return GetRangeConstraint(value <= std::n ...

  3. 九度OJ 1455 珍惜现在,感恩生活 -- 动态规划(背包问题)

    题目地址:http://ac.jobdu.com/problem.php?pid=1455 题目描述: 为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元, ...

  4. Ubuntu下VIM(GVIM)环境配置

    GVIM安装( Ubuntu自带VIM ): 通过应用商店安装或者通过以下安装. sudo apt-get install vim-gnome GVIM配置: 在 家目录 ( ~/ ) 下建立 .vi ...

  5. MySQL数据库原理

    我们知道,数据是信息的载体——一种我们约定了如何解释的符号.在计算机系统中,最常见的应该是文本数据.我们用它记录配置信息,写日志,等等.而在应用程序中,按一定的数据结构来组织数据的方式叫做数据库管理系 ...

  6. php异步请求(可以做伪线程)

    $fp = fsockopen("www.baidu.com", 80, $errno, $errstr, 30); stream_set_blocking($fp,0);     ...

  7. (转载)通过dbgrideh 从数据集中选择合适的记录

    通过dbgrideh 从数据集中选择合适的记录 //---------------------------------------------------------// 通过dbgrideh 从数据 ...

  8. ADO.NET学习小结【1】正在更新...

    小弟正在学习ADO.net有误的地方还请大大们批评指出,小弟在此谢过了 一.ADO.net简述: 以前我们写程序尤其是写和数据库有关的应用程序时,你我都得要了解Microsoft ADO COM对象才 ...

  9. 自己编写的sublime text 3 插件

    一些小功能,比较杂. 具体的功能在这里查看 1.本地环境的php运行结果获取. 2.快捷打开常用的文件,文件夹,url.(ctrl+shift+a) 3.常用的缩进转换. 下边是网络爬虫代码. #py ...

  10. 腾讯面试题 腾讯面试题:给40亿个不重复的unsigned int的整数,没排过序的,然后再给一个数,如何快速判断这个数是否在那40亿个数当中?

    腾讯面试题:给40亿个不重复的unsigned int的整数,没排过序的,然后再给一个数,如何快速判断这个数是否在那40亿个数当中?  这个题目已经有一段时间了,但是腾讯现在还在用来面试.腾讯第一次面 ...