poj2932 Coneology (扫描线)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud
| Time Limit: 5000MS | Memory Limit: 65536K | |
| Total Submissions: 3289 | Accepted: 586 |
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 dominateother 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
这题并不难,和多校的某道题稍微思想上有点像。
问不包含于其他圆内部的圆的数目。
取所有的左端点和右端点,排序后一次取,对于在内部的圆,其外部的圆一定只取到了左端点,那么我们对于当前只取到左端点的圆,只需要判断这个圆的纵坐标是否在那些只取到左端点的圆的纵坐标之间。因为不会相交,所以可以这样搞。
/**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author xyiyy @https://github.com/xyiyy
*/ #include <iostream>
#include <fstream> //#####################
//Author:fraud
//Blog: http://www.cnblogs.com/fraud/
//#####################
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <sstream>
#include <ios>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cctype> using namespace std;
#define mp(X, Y) make_pair(X,Y)
#define pb(X) push_back(X)
#define rep(X, N) for(int X=0;X<N;X++)
#define IT iterator
#define ALL(X) (X).begin(),(X).end() double r[], x[], y[];
vector<pair<double, int> > vec;
set<pair<double, int> > s;
bool mark[];
vector<int> ans; bool contain(int a, int b) {
return ((x[a] - x[b]) * (x[a] - x[b]) + (y[a] - y[b]) * (y[a] - y[b]) <= r[b] * r[b]);
} class poj2932 {
public:
void solve(std::istream &in, std::ostream &out) {
int n;
while (in >> n) {
vec.clear();
s.clear();
ans.clear();
rep(i, n)in >> r[i] >> x[i] >> y[i];
rep(i, n) {
vec.pb(mp(x[i] - r[i], i));
vec.pb(mp(x[i] + r[i], i + n));
}
sort(ALL(vec));
int num = ;
rep(i, vec.size()) {
int j = vec[i].second;
if (j < n) {
set<pair<double, int> >::IT it = s.lower_bound(mp(y[j], j));
if (it != s.end() && contain(j, it->second))continue;
if (it != s.begin() && contain(j, (--it)->second))continue;
s.insert(mp(y[j], j));
mark[j + ] = ;
num++;
} else {
s.erase(mp(y[j - n], j - n));
}
}
out << num << endl;
rep(i, n) {
if (mark[i + ])out << i + << " ";
}
out << endl;
}
}
}; int main() {
std::ios::sync_with_stdio(false);
std::cin.tie();
poj2932 solver;
std::istream &in(std::cin);
std::ostream &out(std::cout);
solver.solve(in, out);
return ;
}
代码君
poj2932 Coneology (扫描线)的更多相关文章
- POJ2932 Coneology【圆扫描线】
POJ2932 Coneology 题意: 给出一些不相交的圆,问有多少个圆不被其他圆包围 题解: 扫描线,把所有圆的左边界和右边界放到\(vector\)里排序,遍历到圆左边界的时候判断是否满足条件 ...
- [扫描线]POJ2932 Coneology
题意:有n个圆 依次给了半径和圆心坐标 保证输入的圆不相交(只有 相离 和 内含/外含 的情况) 问 有几个圆 不内含在其他圆中,并分别列出这几个圆的编号(1~n) (n的范围是[1, 4000 ...
- 计算几何值平面扫面poj2932 Coneology
Coneology Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 4097 Accepted: 859 Descript ...
- poj2932 Coneology
地址:http://poj.org/problem?id=2932 题目: Coneology Time Limit: 5000MS Memory Limit: 65536K Total Subm ...
- 刷题总结——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页 代码 /* ************************************* ...
- POJ 2932 Coneology(扫描线)
[题目链接] http://poj.org/problem?id=2932 [题目大意] 给出N个两两没有公共点的圆,求所有不包含于其它圆内部的圆 [题解] 我们计算出所有点在圆心所有y位置的x值, ...
- Coneology(POJ 2932)
原题如下: Coneology Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 4937 Accepted: 1086 D ...
随机推荐
- bat转向指定的目录路径处
使用bat命令转到指定的盘符路径: cd /d xxxx目录路径. 例如:cd /d D:\abc\efg 则是转到D盘的abc目录下的efg目录处.其中 /d 是指:无论当前bat是在哪个盘符中,都 ...
- HttpHelper工具类
/// <summary> /// 类说明:HttpHelper类,用来实现Http访问,Post或者Get方式的,直接访问,带Cookie的,带证书的等方式,可以设置代理 /// 重要提 ...
- android ConnectivityManager 检查是否有网络
一. ConnectivityManager 概要 ConnectivityManager是网络连接相关的管理器,它主要用于查询网络状态并在网络发生改变时发出状态变化通知.这个类主要负责的下列四个 ...
- C 简单单元测试框架
大约2年前,仿照GTEST写了个简单的C++单元测试框架. http://www.cnblogs.com/imlgc/archive/2012/02/09/2344506.html 后来用C写后台程序 ...
- 转:enum与typedef enum的用法
来自:http://blog.sina.com.cn/s/blog_817a5eb6010146ad.html 作者:于超峰 在程序中,可能需要为某些整数定义一个别名,我们可以利用预处理指令#defi ...
- 第三方账号登录--QQ登录,以及QQ微博账号登录
在QQ登陆测试的时候,刚申请正常登陆,但是由于app未上线,或许是腾讯升级造成的个别时候QQ登陆无法成功会提示下图代码,功能上没啥问题,已经达到 测试效果了.附上腾讯错误代码图(大家测试QQ登陆的时候 ...
- github使用入门 之GIT GUI Windows版
申明下是原创. 这二天网上也看了不少关于github使用的文章,github对代码管理也开始用起来了.这篇给github新手看,大牛们请跳过. github说白了就是版本管理库,最常用的就是程序代码管 ...
- vsftpd,tftp安装配置
一. 对比共同点:都包含ftp不同点:1)vsftpd是一款在Linux发行版中最受推崇的FTP服务器程序.你可以通过ftp客户端上传下载软件.可设置访问用户名密码,或匿名anonymous登陆.默认 ...
- C++中使用stringstream进行类型转换操作
stringstream包括istringstream和ostringstream,提供读写string的功能,使用时需包含stream文件.4个操作:1. stringstream strm; 创建 ...
- 移动web app开发框架
文章地址:http://www.cnblogs.com/soulaz/p/5586787.html jQuery Mobile jQuery Mobile框架能够帮助你快速开发出支持多种移动设备的Mo ...