地址:http://poj.org/problem?id=2932

题目:

Coneology
Time Limit: 5000MS   Memory Limit: 65536K
Total Submissions: 4170   Accepted: 886

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 Rii = 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 Rixiyi separated by spaces, where (xiyi) 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

思路:

  圆的扫描线算法。

 #include <cstdio>
#include <algorithm>
#include <set>
#include <vector> #define MP make_pair
#define lc first
#define rc second using namespace std; const double eps = 1e-;
const int N = 1e5; int vis[N];
double r[N],cr[N][];
pair<double,int>pt[N];
set<pair<double,int> >st;
vector<int>ans;
set<pair<double,int> >::iterator it;
int sc(int a,int b)
{
double ta = (cr[a][]-cr[b][])*(cr[a][]-cr[b][])+(cr[a][]-cr[b][])*(cr[a][]-cr[b][]);
double tb = (r[a]+r[b])*(r[a]+r[b]);
return ta<tb;
}
int main(void)
{
int n;
while(~scanf("%d",&n))
{
st.clear(),ans.clear();
int cnt=;
for(int i=;i<=n;i++)
{
scanf("%lf%lf%lf",r+i,&cr[i][],&cr[i][]);
pt[cnt++]=MP(cr[i][]-r[i],i);
pt[cnt++]=MP(cr[i][]+r[i],i+n);
vis[i]=;
}
sort(pt,pt+cnt);
for(int i=;i<cnt;i++)
{
int k=pt[i].rc;
if(k>n&&vis[k-n])
st.erase(MP(cr[k-n][],k-n));
else if(k<=n)
{
it = st.lower_bound(MP(cr[k][],));
if(it!=st.end()&&sc(k,it->rc)) continue;
if(it!=st.begin()&&sc(k,(--it)->rc)) continue;
st.insert(MP(cr[k][],k));
vis[k]=,ans.push_back(k);
}
}
sort(ans.begin(),ans.end());
printf("%d\n",ans.size());
for(int i=;i<ans.size();i++)
printf("%d%c",ans[i],i==ans.size()-?'\n':' ');
printf("\n");
} return ;
}

poj2932 Coneology的更多相关文章

  1. POJ2932 Coneology【圆扫描线】

    POJ2932 Coneology 题意: 给出一些不相交的圆,问有多少个圆不被其他圆包围 题解: 扫描线,把所有圆的左边界和右边界放到\(vector\)里排序,遍历到圆左边界的时候判断是否满足条件 ...

  2. poj2932 Coneology (扫描线)

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

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

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

  4. [扫描线]POJ2932 Coneology

    题意:有n个圆 依次给了半径和圆心坐标  保证输入的圆不相交(只有 相离 和 内含/外含 的情况)   问 有几个圆 不内含在其他圆中,并分别列出这几个圆的编号(1~n) (n的范围是[1, 4000 ...

  5. 刷题总结——coneology(poj2932 扫描线)

    题目: Description A student named Round Square loved to play with cones. He would arrange cones with d ...

  6. poj 2932 Coneology(扫描线+set)

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

  7. poj 2932 Coneology (扫描线)

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

  8. Coneology(POJ 2932)

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

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

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

随机推荐

  1. TFS Build做Web应用持续集成发布的一个技巧

    由于面向接口编程的关系,许多实现往往是动态注入运行,在一个项目中直接引用实现dll编译是不合理的.通常我们会在Post Build Event中添加一些xcopy命令将运行时才需要的dll复制到输出目 ...

  2. nginx虚拟目录配置

    参考文章:https://blog.csdn.net/whatday/article/details/50649461 1. location ~ ^/awstats/ { root /home/aw ...

  3. java8新特性之Optional类

    NullPointException可以说是所有java程序员都遇到过的一个异常,虽然java从设计之初就力图让程序员脱离指针的苦海,但是指针确实是实际存在的,而java设计者也只能是让指针在java ...

  4. Linux中脚本

    编辑脚本要注意开头 和 修改脚本的权限 1.  开头 #!/bin/bash 如查看/etc路径下的文件,可以编辑 2.  修改权限 chmod 775 脚本文件.sh 如创建一个脚本(test.sh ...

  5. cordova插件file使用时遇到的一个平台相关的问题

    使用cordova-plugin-file可以帮助我们方便的操作app中的图片等文件,分享一下我在用该插件从图库读取图片时遇到的一个平台相关的小问题. 使用场景,我会在APP中新增一张图片,会有一个可 ...

  6. an upstream response is buffered to a temporary file

    an upstream response is buffered to a temporary file

  7. Linux下的反调试技术

    Linux下的反调试技术 2014年01月30日 ⁄ 综合 ⁄ 共 2669字 ⁄ 字号 小 中 大 ⁄ 评论关闭 转自  http://wangcong.org/blog/archives/310 ...

  8. lua打包exe【转】

    可以使用srlua这个工具把lua脚本打包成exe,提供了lua 5.2.5.1.5.0的版本对应的源码. 不过我懒得编译了,发现“白的菜”替懒人编译好了(感谢),点击下载. 解压后出现“luapac ...

  9. 高并发秒杀系统方案(JSR303参数校验)

    <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring- ...

  10. Loadrunner 手动关联技术

    录制成功,回放失败,怀疑和动态数据有关: 1 重新录制一份脚本,两次录制的脚本进行比对,确定动态数据,复制动态数据: 2  找到第一次产生该动态数据的响应对应的相应请求: 1)  拷贝脚本中适当长度的 ...