POJ-2563
| Time Limit: 3000MS | Memory Limit: 65536K | |
| Total Submissions: 10364 | Accepted: 3842 | 
Description
Input
Output
The picture to the right below illustrates the first case from input. 
Sample Input
5
1 1 4 2
2 3 3 1
1 -2.0 8 4
1 4 8 2
3 3 6 -2.0
3
0 0 1 1
1 0 2 1
2 0 3 1
0
Sample Output
Top sticks: 2, 4, 5.
Top sticks: 1, 2, 3.
Hint
Source
/**
题意:给出n条线段,然后取没有被覆盖的;
做法:计算几何(线段相交)
**/
#include <iostream>
#include<cmath>
#include<algorithm>
#include<string.h>
#include<stdio.h>
#define maxn 100000+ 10
using namespace std;
int n,m;
int mmap[maxn];
const double eps = 1e-;
const double PI = acos(-1.0);
int sgn(double x)
{
if(fabs(x) < eps) return ;
if(x < ) return -;
return ;
}
struct Point
{
double x;
double y;
Point() {}
Point(double _x,double _y)
{
x = _x;
y = _y;
}
Point operator - (const Point &b) const
{
return Point(x - b.x,y - b.y);
}
double operator ^(const Point &b) const
{
return x*b.y - y*b.x;
}
double operator *(const Point &b) const
{
return x*b.x + y*b.y;
}
} point[maxn];
struct Line
{
Point s;
Point e;
Line() {}
Line(Point _s,Point _e)
{
s = _s;
e = _e;
}
} line[maxn];
bool inter(Line l1,Line l2)
{
return max(l1.s.x ,l1.e.x) >= min(l2.s.x,l2.e.x) &&
max(l2.s.x,l2.e.x) >= min(l1.s.x,l1.e.x) &&
max(l1.s.y,l1.e.y) >= min(l2.s.y,l2.e.y) &&
max(l2.s.y,l2.e.y) >= min(l1.s.y,l1.e.y) &&
sgn((l2.s - l1.e) ^(l1.s-l1.e) )*sgn((l2.e - l1.e)^(l1.s-l1.e) )<= &&
sgn((l1.s - l2.e) ^(l2.s- l2.e)) *sgn((l1.e - l2.e) ^(l2.s - l2.e)) <=;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif // ONLINE_JUDGE
int n;
while(~scanf("%d",&n))
{
if(n == ) break;
double a,b,c,d;
for(int i=; i<n; i++)
{
scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
line[i] = Line(Point(a,b),Point(c,d));
}
memset(mmap,,sizeof(mmap));
for(int i=; i<n; i++)
{
for(int j=i+; j<n; j++)
{
if(inter(line[i],line[j]))
{
mmap[i] = ;
break;
}
}
}
printf("Top sticks: ");
int res = ;
for(int i=; i<n; i++)
{
if(mmap[i] == )
{
if(res != ) printf(", ");
printf("%d",i+);
res++;
}
}
printf(".\n");
}
return ;
}
POJ-2563的更多相关文章
- POJ 1390 Blocks(记忆化搜索+dp)
		
POJ 1390 Blocks 砌块 时限:5000 MS 内存限制:65536K 提交材料共计: 6204 接受: 2563 描述 你们中的一些人可能玩过一个叫做“积木”的游戏.一行有n个块 ...
 - poj和hdu部分基础算法分类及难度排序
		
最近想从头开始刷点基础些的题,正好有个网站有关于各大oj的题目分类(http://www.pythontip.com/acm/problemCategory),所以写了点脚本把hdu和poj的一些题目 ...
 - POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
		
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
 - POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
		
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
 - POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
		
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
 - POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
		
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
 - POJ 3254. Corn Fields 状态压缩DP (入门级)
		
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
 - POJ 2739. Sum of Consecutive Prime Numbers
		
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
 - POJ 2255. Tree Recovery
		
Tree Recovery Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11939 Accepted: 7493 De ...
 - POJ 2752 Seek the Name, Seek the Fame [kmp]
		
Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17898 Ac ...
 
随机推荐
- BZOJ1085:[SCOI2005]骑士精神——题解+IDA*粗略讲解
			
http://www.lydsy.com/JudgeOnline/problem.php?id=1085 Description 在一个5×5的棋盘上有12个白色的骑士和12个黑色的骑士, 且有一个空 ...
 - javascript forEach无法break,使用every代替
			
every的入口参数是一个返回bool值的函数,在需要break的地方return false,其他均return true,即可达到和break相同的效果 function find(arr2, e ...
 - was(websphere application server)中用apache的httpclient时jar包冲突问题的解决
			
这个问题可以用was的共享库解决. 具体解决方案如下图所示: 对于有多个jar包冲突时,为每个冲突的jar包都新建一个共享库即可. 我之前的错误操作是以为一个共享库可以添加多个冲突的jar包用分号和逗 ...
 - android xml字符串通配
			
1.基本使用方法 xml中定义如下字符串: <string name="buff">%1$d --- %2$s</string> 代码中解析: String ...
 - ACM1881   01背包问题应用
			
01背包问题动态规划应用 acm1881毕业bg 将必须离开的时间限制看作背包容量,先将他们由小到大排序,然后在排完序的数组中对每个实例都从它的时间限制开始(背包容量)到它的延长时间进行遍历: #in ...
 - Idrac6 to manage dell server
			
最近idrac6挂了,java已经升级了 1.安装firefox浏览器,只有火狐是支持idrac最好的 2.安装JDK 3.配置configure java, 4.添加security,edit si ...
 - 仿微信中加载网页时带线行进度条的WebView的实现
			
finddreams:http://blog.csdn.net/finddreams/article/details/44172639 为了仿微信中加载网页时带进度条的WebView的实现,首先我们来 ...
 - 11.nginx upload module + python django 后台 实现视频上传与切片
			
1.需求:支持视频上传并切片,支持通过m3u8文件播放 2.视频切片的上一节已经谈过,这一节主要是视频上传的处理 第一步:upload-module模块安装 -----------首先下载upload ...
 - python 基础--pip(转)
			
感谢:http://www.cnblogs.com/csucat/p/4897695.html python需要用到一些其他的库,可以手动去各个库的官网下载,自己安装:也可以安装pip,使用pip可以 ...
 - 策略模式 C#
			
策略模式定义了一系列的算法,并将每一个算法封装起来,而且使它们还可以相互替换.策略模式让算法独立于使用它的客户而独立变化. 抽象策略角色: 策略类,通常由一个接口或者抽象类实现. 具体策略角色:包装了 ...