地址: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. iOS开发中id、NSObject *、id、instancetype四者有什么区别?

      在使用Objective-C语言进行iOS应用开发的时候,常常会涉及到id.NSObject *.id.instancetype这四个概念的使用,但这四者也是iOS初学者最易混淆的内容,下面小编看 ...

  2. 初始react

    很久就期待学习react了,惰性,一直都没有去翻阅react的资料,最近抽空,简单的了解了一下react,先记录一下,后续慢慢的学习. 一.ReactJS简介 React 起源于 Facebook 的 ...

  3. yii---判断POST请求

    我们在进行数据的提交的时候,很多时候会判断请求状态来进行不同的选择.常见的就是判断POST以及GET的请求方式,下面是YII判断POST请求的代码示例: public function actionP ...

  4. OpenCV Save CvRect to File 保存CvRect变量到文件

    在OpenCv中,我们有时候需要查看CvRect变量的值,我们可以通过将其保存到文件来查看,保存的代码如下: void writeCvRectToFile(CvRect &rect, cons ...

  5. saltstack------安装篇

    一.环境准备 系统:centos7   and centos6.8 IP 系统 172.16.1.10 centos7 172.16.1.11 centos7 172.16.1.21 centos6. ...

  6. PAT甲1077 Kuchiguse【字符串】【暴力】【Hash】【二分】

    1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Personal ...

  7. poj2492 A Bug's Life【并查集】

    Background  Professor Hopper is researching the sexual behavior of a rare species of bugs. He assume ...

  8. 2.5BatchNormalzation

    BatchNormalzation是一种解决深度神经网络层数太多,而没有办法有效前向传递的问题,因为每层的输出值都会有不同的均值和方差,所以输出数据的分布也不一样. 如果对于输入的X*W本身得到的值通 ...

  9. JAVA补充-接口

    1.接口详解 package com.neusoft.interfaced; /** * 接口: * 语法:interface 接口名{ * public static final 变量1=值1: * ...

  10. grpc protobuf

    1.ProtoBuffer是google的一款非常高效的数据传输格式框架 2.一个方法仅能接受一个参数 3.对于定义的message,每个值都有一个唯一的number类型的数字,根据官方文档的解释:它 ...