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. (注意此题无相 ...
随机推荐
- C# 递归与非递归算法与数学公式
1.递归 递归:程序调用自身的编程技巧称为递归(recursion). 优点是:代码简洁,易于理解. 缺点是:运行效率较低. 递归思想:把问题分解成规模更小,但和原问题有着相同解法的问题. 1)下面是 ...
- 替换Quartus 自带编辑器 (转COM张)
正文 此处以Quartus II 11.1和Notepad++ v5.9.6.2为例. 1. 使用QII自动调用Notepad++来打开HDL.sdc.txt等文件:并且可以在报错的时候,Notepa ...
- 关于nagios系统下使用shell脚本自定义监控插件的编写
在自已编写监控插件之前我们首先需要对nagios监控原理有一定的了解 Nagios的功能是监控服务和主机,但是他自身并不包括这部分功能,所有的监控.检测功能都是通过各种插件来完成的. 启动Nagios ...
- 【BZOJ3328】PYXFIB 数论+矩阵乘法
[BZOJ3328]PYXFIB Description Input 第一行一个正整数,表示数据组数据 ,接下来T行每行三个正整数N,K,P Output T行,每行输出一个整数,表示结果 Sampl ...
- iOS - ipa安装包大小优化
在App Store上显示的下载大小和实际下载下来的大小,我们通过下表做一个对比: iPhone型号 系统 AppStore 显示大小 下载到设备大小 iPhone6 10.2.1 91.5MB 88 ...
- /usr/bin/ld: i386:x86-64 architecture of input file `command.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `command.o' is incompatible with i386 output 出现这 ...
- Qt qDebug() 的使用方法
在Qt程序调试的时候,经常需要打印一些变量,那么我们就需要使用qDebug()函数,这种函数有两种使用方法,如下所示: QString s = "Jack"; qDebug() & ...
- mysqladmin 命令详解
mysqladmin是一个执行管理操作的客户端程序.它可以用来检查服务器的配置和当前状态.创建和删除数据库等. mysqladmin 工具的使用格式: mysqladmin [option] comm ...
- zTree实现节点修改的实时刷新
一.应用场景 在实际应用中会遇到动态操作树各节点的需求,在增加树节点后如何实时动态刷新树就十分有必要了. 二.项目实践 比如要在test1234节点下新建子节点,首先要选中test1234节点,添 ...
- 5 Tips for Building a Winning DevOps Culture
对于企业来说,前途未卜的改变往往很难发生,就像航海一样,重复的往往是久经验证的安全航线,这点在DevOps文化的构建上同样如此.近日,CA Technologies的高级策略师Peter Waterh ...