TTTTTTTTTTTTTTT poj 2932 Coneology 平面扫描+STL
题目链接
题意:有n个圆,圆之间不存在相交关系,求有几个不被其他任何圆包含的圆,并输出圆的编号;
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
#define MM(a) memset(a,0,sizeof(a))
typedef long long ll;
typedef unsigned long long ULL;
const int mod = 1000000007;
const double eps = 1e-10;
const int inf = 0x3f3f3f3f;
const int big=50000;
int max(int a,int b) {return a>b?a:b;};
int min(int a,int b) {return a<b?a:b;};
struct circle{
double x,y,r;
}c[40005]; bool inter(int i,int j)
{
double dx=c[i].x-c[j].x,dy=c[i].y-c[j].y;
return dx*dx+dy*dy<=c[j].r*c[j].r;
} int main()
{
int n;
while(~scanf("%d",&n))
{
double x,y,r;
vector<pair<double,int> > events;
events.clear();
for(int i=1;i<=n;i++)
{
scanf("%lf %lf %lf",&c[i].r,&c[i].x,&c[i].y);
events.push_back(make_pair(c[i].x-c[i].r,i));
events.push_back(make_pair(c[i].x+c[i].r,i+n));
}
sort(events.begin(),events.end()); set<pair<double,int> > outers;
vector<int> ans;
for(int i=0;i<events.size();i++)
{
int id;
if(events[i].second<=n)
{
id=events[i].second;
set<pair<double,int> >::iterator it=outers.lower_bound(make_pair(c[id].y,id));
if(it!=outers.end()&&inter(id,it->second)) continue;
if(it!=outers.begin()&&inter(id,(--it)->second)) continue;
ans.push_back(id);
outers.insert(make_pair(c[id].y,id));
}
else
{
id=events[i].second-n;
outers.erase(make_pair(c[id].y,id));
}
} sort(ans.begin(),ans.end());
printf("%d\n",ans.size());
for(int i=0;i<ans.size()-1;i++)
printf("%d ",ans[i]);
printf("%d\n",ans[ans.size()-1]);
}
return 0;
}
分析:扫描线+set的使用
TTTTTTTTTTTTTTT poj 2932 Coneology 平面扫描+STL的更多相关文章
- POJ 2932 Coneology(扫描线)
[题目链接] http://poj.org/problem?id=2932 [题目大意] 给出N个两两没有公共点的圆,求所有不包含于其它圆内部的圆 [题解] 我们计算出所有点在圆心所有y位置的x值, ...
- poj 2932 Coneology(扫描线+set)
Coneology Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 3574 Accepted: 680 Descript ...
- POJ 2932 Coneology计算最外层圆个数
平面上有n个两两没有公共点的圆,i号圆的圆心在(xi,yi),半径为ri,编号从1开始.求所有最外层的,即不包含于其他圆内部的圆.输出符合要求的圆的个数和编号.n<=40000. (注意此题无相 ...
- poj 2932 Coneology (扫描线)
题意 平面上有N个两两不相交的圆,求全部最外层的,即不被其它圆包括的圆的个数并输出 思路 挑战程序竞赛P259页 代码 /* ************************************* ...
- POJ 2932 平面扫描 /// 判断圆的包含关系
题目大意: 平面上有n个两两不相交的圆,给定圆的圆心(x,y)和半径 r 求所有最外层的 即 不包含于其他圆内部的圆 挑战258页 平面扫描 记录所有圆的左端和右端 排序后 逐一扫描 将到当前圆为止的 ...
- Coneology(POJ 2932)
原题如下: Coneology Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 4937 Accepted: 1086 D ...
- POJ 2932 圆扫描线
求n个圆中没有被包含的圆.模仿扫描线从左往右扫,到左边界此时如有3个交点,则有3种情况,以此判定该圆是否被离它最近的圆包含,而交点和最近的圆可以用以y高度排序的Set来维护.因此每次到左边界插入该圆, ...
- 基于正向扫描的并行区间连接平面扫描算法(IEEE论文)
作者: Panagiotis Bouros ∗Department of Computer ScienceAarhus University, Denmarkpbour@cs.au.dkNikos M ...
- poj 3253 Fence Repair (STL优先队列)
版权声明:本文为博主原创文章,未经博主同意不得转载. vasttian https://blog.csdn.net/u012860063/article/details/34805369 转载请注明出 ...
随机推荐
- Python 过滤HTML实体符号简易方法
html_tag = {' ': '\n', '"': '\"', '&': '', '<': '<', '>': '>', '' ...
- python线程中的同步问题
多线程开发可能遇到的问题 假设两个线程t1和t2都要对num=0进行增1运算,t1和t2都各对num修改1000000次,num的最终的结果应该为2000000.但是由于是多线程访问,有可能出现下面情 ...
- python:split()函数
描述 Python 内置函数 指定分隔符对字符串进行切片 如果参数 num 有指定值,则仅分隔 num 个子字符串 返回分割后的字符串列表. 语法 str.split(str="" ...
- Hadoop伪分布式重启正确流程
既然是伪分布式,那就不可避免的设计到重启Hadoop服务或者重启Hadoop服务器的情况,正确的停止和重启是很有必要的. 首先是Hadoop服务的停止,使用 ./sbin/stop-all.sh脚本来 ...
- NLP 基于kashgari和BERT实现中文命名实体识别(NER)
准备工作,先准备 python 环境,下载 BERT 语言模型 Python 3.6 环境 需要安装kashgari Backend pypi version desc TensorFlow 2.x ...
- thinkphp漏洞集合
整合了一个集合,方便查询 thinkphp 5.0.22 1.http://192.168.1.1/thinkphp/public/?s=.|think\config/get&name=dat ...
- 配置Linux静态IP地址
- 如何卸载rpm
首先通过 rpm -q <关键字> 可以查询到rpm包的名字 或者rpm -qa|grep 关键字 然后 调用 rpm -e <包的名字> 删除特定rpm包 如果遇到依赖,无 ...
- Object Pascal异常的种类
- flaskbb部署笔记
https://flaskbb.org/ https://github.com/sh4nks/flaskbb/ https://flaskbb.readthedocs.io/en/latest/ins ...