题目:

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

题解:

思路参见:http://www.cppblog.com/Wangzhihao/articles/109348.html

这道题能想到扫描线也是佩服啊······通过这道题也学到了set里加pair还有指针的骚操作

代码:

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cctype>
#include<set>
using namespace std;
set<pair<double,int> >st;
const int N=8e5+;
double x[N],y[N],r[N];
int ans[N],cnt,n;
struct node
{
double x;int id,op;
}q[N];
inline bool cmp(node a,node b)
{
return a.x<b.x;
}
inline bool jud(int a,int b)
{
return (x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b])<=(r[a]-r[b])*(r[a]-r[b]);
}
int main()
{
//freopen("a.in","r",stdin);
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%lf%lf%lf",&r[i],&x[i],&y[i]);
q[i].x=x[i]-r[i],q[i].id=i,q[i].op=;
q[i+n].x=x[i]+r[i],q[i+n].id=i,q[i+n].op=-;
}
sort(q+,q+*n+,cmp);
for(int i=;i<=*n;i++)
{
if(q[i].op==)
{
set<pair<double,int> > ::iterator l=st.lower_bound(make_pair(y[q[i].id],q[i].id));
if(l!=st.end()&&jud(q[i].id,l->second)) continue;
if(l!=st.begin()&&jud(q[i].id,(--l)->second)) continue;
ans[++cnt]=q[i].id;
st.insert(make_pair(y[q[i].id],q[i].id));
}
else
st.erase(make_pair(y[q[i].id],q[i].id));
}
cout<<cnt<<endl;
sort(ans+,ans+cnt+);
for(int i=;i<=cnt;i++)
cout<<ans[i]<<" ";
return ;
}
												

刷题总结——coneology(poj2932 扫描线)的更多相关文章

  1. $2019$ 暑期刷题记录1:(算法竞赛DP练习)

    $ 2019 $ 暑期刷题记录: $ POJ~1952~~BUY~LOW, BUY~LOWER: $ (复杂度优化) 题目大意:统计可重序列中最长上升子序列的方案数. 题目很直接的说明了所求为 $ L ...

  2. LeetCode刷题系列

    LeetCode 我们工作面试和提高自身数据结构和算法能力的时候往往需要刷刷题,我选择LeetCode是通过一个留学论坛了解的.专业,覆盖语种全面. 提前说说刷题的心得: 尽量手写代码,少使用IDE的 ...

  3. ife任务刷题总结(一)-css reset与清除浮动

    本文同时发布于本人的个人网站www.yaoxiaowen.com 百度创办的前端技术学院,是一个面向大学生的前端技术学习平台.虽然只有大学生才有资格报名,提交代码进行比赛排名.但是这并不妨碍我们这些初 ...

  4. 刷题ING...

    我用codeVS刷题.. 努力准备!!

  5. XidianOJ 1020 ACMer去刷题吧

    题目描述 刷题是每个ACMer必由之路,已知某oj上有n个题目,第i个题目小X能做对的概率为Pi(0<=Pi<=1,1<=i<=n) 求小X至少做对k道题的概率 输入 第一行输 ...

  6. 【BZOJ-4590】自动刷题机 二分 + 判定

    4590: [Shoi2015]自动刷题机 Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 156  Solved: 63[Submit][Status ...

  7. NOI题库分治算法刷题记录

    今天晚自习机房刷题,有一道题最终WA掉两组,极其不爽,晚上回家补完作业欣然搞定它,特意来写篇博文来记录下 (最想吐槽的是这个叫做分治的分类,里面的题目真的需要分治吗...) 先来说下分治法 分治法的设 ...

  8. NOI题库刷题日志 (贪心篇题解)

    这段时间在NOI题库上刷了刷题,来写点心得和题解 一.寻找平面上的极大点 2704:寻找平面上的极大点 总时间限制:  1000ms  内存限制:  65536kB 描述 在一个平面上,如果有两个点( ...

  9. 用js刷题的一些坑

    leecode可以用js刷题了,我大js越来越被认可了是吧.但是刷题中会因为忽略js的一些特性掉入坑里.我这里总结一下我掉过的坑. 坑1:js中数组对象是引用对象 js中除了object还有数组对象也 ...

随机推荐

  1. [dp uestc oj] G - 邱老师玩游戏

    G - 邱老师玩游戏 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submi ...

  2. Object Modeling

    https://developer.apple.com/library/content/documentation/General/Conceptual/CocoaEncyclopedia/Objec ...

  3. MySQL8 Authentication plugin 'caching_sha2_password' cannot be loaded

    这是因为mysql8 和以前密码的验证方式不同,可以先从命令行进入     MySQL  -uroot -p       然后输入 ALTER USER 'root'@'localhost' IDEN ...

  4. Java 可变长参数列表

    Java中定义了变长参数,允许在调用方法时传入不定长度的参数. 定义及调用 在定义方法时,在最后一个形参后加上三点 …,就表示该形参可以接受多个参数值,多个参数值被当成数组传入.上述定义有几个要点需要 ...

  5. Python -- 函数之推导式

    5.12 推导式 l = [] for i in range(1,11): l.append(i) print(l) # 用列表推导式 (一行搞定) l = [i for i in range(1,1 ...

  6. Windows系统安装docker

    下载安装包 官网 点击 Get Started ,打开入门页面,往下拉,找到 Download for Windows 打开 下载页面 ,点击 Please Login To Download ,要注 ...

  7. Java基础面试操作题:Java代理工厂设计模式 ProxyFactory 有一个Baby类,有Cry行为,Baby可以配一个保姆 但是作为保姆必须遵守保姆协议:能够处理Baby类Cry的行为,如喂奶、哄睡觉。

    package com.swift; public class Baby_Baomu_ProxyFactory_Test { public static void main(String[] args ...

  8. 【构造题 贪心】cf1041E. Tree Reconstruction

    比赛时候还是太慢了……要是能做快点就能上分了 Monocarp has drawn a tree (an undirected connected acyclic graph) and then ha ...

  9. GIMP如何制作一只大佬猫头像

    新建文件File -> 设置宽度为24px,高度5px:高级选项中将背景图片设置为无色 使用铅笔,前景色设为黑色,画出眼镜的模样,画出反光效果:将前景色设为灰色 放大图片,右击空白区域-> ...

  10. gulp的安装和使用

    安装nodejs -> 全局安装gulp -> 项目安装gulp以及gulp插件 -> 配置gulpfile.js -> 运行任务 1.去nodejs官网安装nodejs 2. ...