POJ 1127_Jack Straws】的更多相关文章

%: 对于二维向量p1=(x1,y1),p2=(x2,y2),定义内积p1⋅p2=x1x2+y1y2,外积p1×p2=x1y2−y1x2,则判断点q是否在线段p1−p2上: 先利用外积判断q是否在直线p1p2上,(p1−q)×(p2−q)=0; 再利用内积判断q是否在线段p1−p2上,(p1−q)×(p2−q)≤0; 设直线p1−p2上的点为p1+t(p2−p1),则该点在线段q1−q2上有: (q1−q2)×(p1+t(p2−p1)−q2)=0 则交点为: p1+(q1−q2)×(q2−p1)…
http://poj.org/problem?id=1127   Description In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table and players try to remove them one-by-one without disturbing the other straws. Here, we are only concerned wi…
Jack Straws Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2911   Accepted: 1322 Description In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table and players try to remove them one-by-one witho…
[题目链接] http://poj.org/problem?id=1127 [题目大意] 在二维平面中,给出一些木棍的左右端点,当木棍相交或者间接相交时 我们判断其连通,给出一些询问,问某两个木棍是否连通 [题解] 我们首先记录直接相连的木棍,然后对图跑一遍floyd算法,就能预处理出所有答案. [代码] #include <cstdio> #include <algorithm> #include <cmath> #include <cstring> us…
In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table and players try to remove them one-by-one without disturbing the other straws. Here, we are only concerned with if various pairs of straws are connected b…
Jack Straws Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5428   Accepted: 2461 Description In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table and players try to remove them one-by-one witho…
Jack Straws In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table and players try to remove them one-by-one without disturbing the other straws. Here, we are only concerned with if various pairs of straws are…
原题如下: Jack Straws Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5555   Accepted: 2536 Description In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table and players try to remove them one-by-one…
题目链接 抄的模版,居然1Y了.就是简单的线段相交+并查集. #include <iostream> #include <cstring> #include <cstdio> #include <cstdlib> #include <cmath> using namespace std; #define eps 1e-8 #define zero(x) (((x) > 0?(x):(-x))<eps) struct point { d…
题意: 给出一系列线段,判断某两个线段是否连通. 思路: 根据线段相交情况建立并查集, 在同一并查集中则连通. (第一反应是强连通分量...实际上只要判断共存即可, 具体的方向啊是没有关系的..) 并查集合并的时候是根节点合并. 快速排斥试验不是必需的, 大规模数据可能是个优化吧. 跨立试验注意共线的情况. 共线判断注意与y 轴平行的情况. #include <cstdio> #include <cstring> #include <cmath> using names…