POJ3304 Segments 【线段直线相交】】的更多相关文章

题意: 给出n条线段两个端点的坐标,问所有线段投影到一条直线上,如果这些所有投影至少相交于一点就输出Yes!,否则输出No!. 思路: 计算几何.这道题要思考到两点: 1:把问题转化为是否存在一条直线与每条线段都有交点.证明:若存在一条直线l和所有线段相交,作一条直线m和l垂直,则m就是题中要求的直线,所有线段投影的一个公共点即为垂足. 2:枚举两两线段的各一个端点,连一条直线,再判断剩下的线段是否都和这条直线有交点.证明:若有l和所有线段相交,则可保持l和所有线段相交,左右平移l到和某一线段交…
Segments Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7739   Accepted: 2316 Description Given n segments in the two dimensional space, write a program, which determines if there exists a line such that after projecting these segments…
POJ 3304  Segments 题意:给定n(n<=100)条线段,问你是否存在这样的一条直线,使得所有线段投影下去后,至少都有一个交点. 思路:对于投影在所求直线上面的相交阴影,我们可以在那里作一条线,那么这条线就和所有线段都至少有一个交点,所以如果有一条直线和所有线段都有交点的话,那么就一定有解. 怎么确定有没直线和所有线段都相交?怎么枚举这样的直线?思路就是固定两个点,这两个点在所有线段上任意取就可以,然后以这两个点作为直线,去判断其他线段即可.为什么呢?因为如果有直线和所有线段都相…
题目链接:POJ 3304 Problem Description Given n segments in the two dimensional space, write a program, which determines if there exists a line such that after projecting these segments on it, all projected segments have at least one point in common. Input…
题目传送门:POJ 3304 Segments Description Given n segments in the two dimensional space, write a program, which determines if there exists a line such that after projecting these segments on it, all projected segments have at least one point in common. Inp…
题目大意:给出n条线段,问是否存在一条直线,使得n条线段在直线上的投影有至少一个公共点. 题目思路:如果假设成立,那么作该直线的垂线l,该垂线l与所有线段相交,且交点可为线段中的某两个交点 证明:若有l和所有线段相交,则可保持l和所有线段相交,左右平移l到和某一线段交于端点停止("移不动了").然后绕这个交点旋转.也是转到"转不动了"(和另一线段交于其一个端点)为止.这样就找到了一个新的l满足题意,而且经过其中两线段的端点. 如何判断直线是否与线段相交:如果线段的两…
http://poj.org/problem?id=3304 Segments Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9449   Accepted: 2902 Description Given n segments in the two dimensional space, write a program, which determines if there exists a line such that a…
// 判断线段和直线相交 POJ 3304 // 思路: // 如果存在一条直线和所有线段相交,那么平移该直线一定可以经过线段上任意两个点,并且和所有线段相交. #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #includ…
链接: http://poj.org/problem?id=1039 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#problem/B Pipe Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8350   Accepted: 2501 Description The GX Light Pipeline Company started to prep…
F - Cycling Roads     Description When Vova was in Shenzhen, he rented a bike and spent most of the time cycling around the city. Vova was approaching one of the city parks when he noticed the park plan hanging opposite the central entrance. The plan…