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 转载请注明出 ...
随机推荐
- Manacher模版
现在讲的也是一种处理字符串的方法,叫做Manacher,有点像“马拉车” 1179: [视频][Manacher]最长回文子串 时间限制: 1 Sec 内存限制: 128 MB提交: 209 解决 ...
- CF 403D Beautiful Pairs of Numbers
The sequence of integer pairs (a1, b1), (a2, b2), ..., (ak, bk) is beautiful, if the following state ...
- js小数和百分数的转换
一.百分数转化为小数 function toPoint(percent){ var str=percent.replace("%",""); str= str/ ...
- spring boot本地开发与docker容器化部署的差异
spring boot本地开发与docker容器化部署的差异: 1. 文件路径及文件名区别大小写: 本地开发环境为windows操作系统,是忽略大小写的,但容器中区分大小写 2. docker中的容器 ...
- O021、创建 Image
参考https://www.cnblogs.com/CloudMan6/p/5393376.html 本节演示如何通过 Web GUI 和 CLI 两种方法创建image. OpenStack ...
- hive报错java.sql.SQLException: null, message from server: "Host '192.168.126.100' is not allowed to connect to this MySQL server"
- 原生JS+CSS实现日期插件
笔者最近在学习Element UI,觉得它提供的日期选择器既简单又美观,于是仿照着写了一个日期插件.笔者使用到的技术有ES5.CSS和HTML,控件兼容IE10+和谷歌浏览器.有一点需要注意,笔者使用 ...
- css3实现div自动左右动
<!DOCTYPE html> <meta charset="UTF-8"/> <html> <head> <style> ...
- CentOS查看Java进程并部署jar包
查看Java进程获取pid号:ps -ef|grep java|grep -v grep 部署Javajar包并指定输出日志文件(null不输出):nohup java -jar xx.jar > ...
- Python爬虫之简单爬虫框架实现
简单爬虫框架实现 目录 框架流程 调度器url管理器 网页下载器 网页解析器 数据处理器 具体演示效果 框架流程 调度器 #导入模块 import Url_Manager import parser_ ...