poj2932 Coneology
地址:http://poj.org/problem?id=2932
题目:
| 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 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
思路:
圆的扫描线算法。
#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的更多相关文章
- POJ2932 Coneology【圆扫描线】
POJ2932 Coneology 题意: 给出一些不相交的圆,问有多少个圆不被其他圆包围 题解: 扫描线,把所有圆的左边界和右边界放到\(vector\)里排序,遍历到圆左边界的时候判断是否满足条件 ...
- poj2932 Coneology (扫描线)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Coneology Time Limit: 5000MS Memory Lim ...
- 计算几何值平面扫面poj2932 Coneology
Coneology Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 4097 Accepted: 859 Descript ...
- [扫描线]POJ2932 Coneology
题意:有n个圆 依次给了半径和圆心坐标 保证输入的圆不相交(只有 相离 和 内含/外含 的情况) 问 有几个圆 不内含在其他圆中,并分别列出这几个圆的编号(1~n) (n的范围是[1, 4000 ...
- 刷题总结——coneology(poj2932 扫描线)
题目: Description A student named Round Square loved to play with cones. He would arrange cones with d ...
- poj 2932 Coneology(扫描线+set)
Coneology Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 3574 Accepted: 680 Descript ...
- poj 2932 Coneology (扫描线)
题意 平面上有N个两两不相交的圆,求全部最外层的,即不被其它圆包括的圆的个数并输出 思路 挑战程序竞赛P259页 代码 /* ************************************* ...
- Coneology(POJ 2932)
原题如下: Coneology Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 4937 Accepted: 1086 D ...
- POJ 2932 Coneology计算最外层圆个数
平面上有n个两两没有公共点的圆,i号圆的圆心在(xi,yi),半径为ri,编号从1开始.求所有最外层的,即不包含于其他圆内部的圆.输出符合要求的圆的个数和编号.n<=40000. (注意此题无相 ...
随机推荐
- 使用HtmlAgilityPack解析html
HtmlAgilityPack是.net下使用xPath来解析html的类库,可以方便的做html的页面分析处理 项目地址: http://htmlagilitypack.codeplex.com/ ...
- 解决-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variabl
1.添加M2_HOME的环境变量 2.Preference->Java->Installed JREs->Edit 选择一个jdk, 添加 -Dmaven.multiModuleP ...
- SOA架构商城二 框架搭建
1.创建父工程 创建Maven工程pingyougou-parent,选择packaging类型为pom ,在pom.xml文件中添加锁定版本信息dependencyManagement与plugin ...
- python---不支持中文注释解决办法
很神奇的一件事儿,pycharm不支持中文注释,具体解决办法: #-*- coding: utf- -*- 具体使用:
- Elasticsearch 不同的搜索类型之间的区别
1.match 轻量级搜索 GET /wymlib/_search { "query": { "match": { "title": ...
- ELK之收集tomcat访问日志
把tomcat访问日志转换成json格式然后收集 修改配置文件conf/server.xml把日志输出改成json格式 添加logstash配置文件(日志按天切割可以使用*进行匹配所有)
- ubuntu16.04下安装pycharm
下面开始教程 先在PyCharm官网下载安装包 链接:https://www.jetbrains.com/pycharm/download/#section=linux 选择平台为Linux,可以看到 ...
- PyQT5-QSlide滑块
""" QSlider:是一个小滑块组件,这个小滑块能够被拖着一起滑动,用于通常修改具有一定范围的数据 Author: dengyexun DateTime: 2018. ...
- 看病要排队--hdu1873
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1873 运用优先队列写就行了 #include<stdio.h> #include< ...
- BZOJ4614 UVA1742 Oil 计算几何+搜索+扫描线
正解:计算几何+搜索+扫描线 解题报告: 传送门 哇我是真的觉得这题很妙了!各个方面都很妙啊... 首先有一个很重要的结论:最优线一定可以通过各种变换(旋转/平移)使得经过一条线段的左端点(...并不 ...