//UVALive7461 - Separating Pebbles 判断两个凸包相交 #include <bits/stdc++.h> using namespace std; #define LL long long typedef pair<int,int> pii; const int inf = 0x3f3f3f3f; ; #define clc(a,b) memset(a,b,sizeof(a)) ; ; void fre() {freopen("in.txt…
给定一个单链表,只给出头指针h: 1.如何判断是否存在环? 2.如何知道环的长度? 3.如何找出环的连接点在哪里? 4.带环链表的长度是多少? 解法: 1.对于问题1,使用追赶的方法,设定两个指针slow.fast,从头指针开始,每次分别前进1步.2步.如存在环,则两者相遇:如不存在环,fast遇到NULL退出. 2.对于问题2,记录下问题1的碰撞点p,slow.fast从该点开始,再次碰撞所走过的操作数就是环的长度s. 3.问题3:有定理:碰撞点p到连接点的距离=头指针到连接点的距离,因此,分…
题意: 给出n个红点,m个蓝点.问是否存在一条直线使得红点和蓝点分别分布在直线的两侧,这些点不能再直线上. 分析: 求出两种点的凸包,如果两个凸包相离的话,则存在这样一条直线. 判断凸包相离需要判断这两件事情: 任何一个凸包的任何一个顶点不能在另一个凸包的内部或者边界上. 两个凸包的任意两边不能相交. 二者缺一不可,第一条很好理解,但为什么还要判断第二条,因为存在这种情况: 虽然每个凸包的顶点都在另一个凸包的外部,但两个凸包明显是相交的. //#define LOCAL #include <cs…
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 199    Accepted Submission(s): 132   Problem Description Many geometry(几何)problems were designed in the ACM/…
http://poj.org/problem?id=2653 题目大意:有n根各种长度的棍   一同洒在地上 求在最上面的棍子有那几个 分析:  我刚开始想倒着遍历  因为n是100000   想着会超时吧  后来一看说  在上面的不会超过1000个 这就放心了 简单优化一下就过了 最后一个肯定是在最上面的 让后从他的下一个开始  每一个跟他相交的都是在他下面的  下一次就直接不循环他了 但是一直wa   彻底懵逼了 后来看了学长博客  他是正这循环  只要有跟他相交的就跳出  然后我就正这便利…
#include<cstdio> #include<cmath> #include<iostream> #include<algorithm> #include<vector> #include<stack> #include<cstring> #include<queue> #include<set> #include<string> #include<map> #incl…
2019 杭电多校 1 1013 题目链接:HDU 6590 比赛链接:2019 Multi-University Training Contest 1 Problem Description After returning with honour from ICPC(International Cat Programming Contest) World Finals, Tom decides to say goodbye to ICPC and start a new period of l…
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6837 Accepted Submission(s): 3303 Problem Description Many geometry(几何)problems were designed in the ACM/ICPC. A…
You can Solve a Geometry Problem too Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6425    Accepted Submission(s): 3099 Problem Description Many geometry(几何)problems were designed in the ACM/I…
模板敲错了于是WA了好几遍…… 判断由红点和蓝点分别组成的两个凸包是否相离,是输出Yes,否输出No. 训练指南上的分析: 1.任取红凸包上的一条线段和蓝凸包上的一条线段,判断二者是否相交.如果相交(不一定是规范相交,有公共点就算相交),则无解 2.任取一个红点,判断是否在蓝凸包内.如果是,则无解.蓝点红凸包同理. 其中任何一个凸包退化成点或者线段时需要特判. 其实只需要把上面两个判断顺序颠倒一下,就可以不需要特判. 先判断点是否在凸包内,因为这个考虑了点在凸包边界上的情况,所以后面判凸包线段是…
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2640 http://www.spoj.com/problems/SPOINTS/en/ http://poj.org/problem?id=3805 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1298 要…
题目链接:POJ 3805 Problem Description Numbers of black and white points are placed on a plane. Let's imagine that a straight line of infinite length is drawn on the plane. When the line does not meet any of the points, the line divides these points into t…
Pick-up sticks Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1872    Accepted Submission(s): 706 Problem Description Stan has n sticks of various length. He throws them one at a time on the fl…
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…
SQL中常常要判断两个时间段是否相交,该如何判断呢?比如两个时间段(S1,E1)和(S2,E2).我最先想到的是下面的方法一.方法一:(S1 BETWEEN S2 AND E2) OR (S2 BETWEEN S1 AND E1).很好理解:一个时间段的开始时间S1在另一个时间中间(S2,E2),或者开始时间S2在另一个时间中间(S1,E1),这个方法比较繁琐 方法二:本方法先考虑这两段时间什么情况下不相交,如图:    -----+-----------------+-------------…
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…
最近需要用到矩形相交算法的简单应用,所以特地拿一个很简单的算法出来供新手参考,为什么说是给新手的参考呢因为这个算法效率并不是很高,但是这个算法只有简简单单的三行.程序使用了两种方法来判断是否重叠/相交,如果有兴趣可以看一下,如果觉得有bug可以留言.代码仅供参考. C#中矩形的方法为Rectangl(起始点坐标, 矩形的大小)或Rectangl(起始点x坐标, 起始点y坐标, 矩形宽, 矩形高),起始点为矩形区域的左上角. 方法一 姑且叫做“井字法”吧,延长其中一个矩形的四边使其形成一“井”字(…
<?php $s = is_rect_intersect(1,2,1,2,4,5,0,3); var_dump($s); /* 如果两个矩形相交,那么矩形A B的中心点和矩形的边长是有一定关系的. Case 2345中,两个中心点间的距离肯定小于AB边长和的一半. Case 1中就像等了. 设A[x01,y01,x02,y02]  B[x11,y11,x12,y12]. 矩形A和矩形B物理中心点X方向的距离为Lx:abs( (x01+x02)/2 – (x11+x12) /2) 矩形A和矩形B物…
Separating Pebbles 题目链接: http://acm.hust.edu.cn/vjudge/contest/127401#problem/H Description http://7xjob4.com1.z0.glb.clouddn.com/1e1638de1146450534631815cbf822c6 Input The first line of the input contains an integer K (K ≤ 20) indicating the number…
#include <iostream> #include <cmath> #include <vector> #include <string.h> #include <stdlib.h> #include <stdio.h> #include <algorithm> using namespace std; #define MAX_N 110 /*------------------常量区----------------…
Home Web Board ProblemSet Standing Status Statistics   Problem D: 判断两个圆之间的关系 Problem D: 判断两个圆之间的关系 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 381  Solved: 325[Submit][Status][Web Board] Description 定义Point类,包括double类型的两个属性,分别表示二维空间中一个点的横纵坐标:定义其必要…
// 判断线段和直线相交 POJ 3304 // 思路: // 如果存在一条直线和所有线段相交,那么平移该直线一定可以经过线段上任意两个点,并且和所有线段相交. #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #includ…
Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4628   Accepted: 1434 Description The DIY Furniture company specializes in assemble-it-yourself furniture kits. Typically, the pieces of wood are attached to one another using a wooden peg…
Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 8351 Accepted: 3068 Description Stan has n sticks of various length. He throws them one at a time on the floor in a random way. After finishing throwing, Stan tries to find the top sticks, th…
题意:在二维平面中,给定一些线段,然后判断在某直线上的投影是否有公共点. 转化,既然是投影,那么就是求是否存在一条直线L和所有的线段都相交. 证明: 下面给出具体的分析:先考虑一个特殊的情况,即n=1的时候,如下图,线段AB在直线L上的投影为线段A'B',则过任意介于A'B'之间的点C'做直线L的垂线必交线段AB与一点C:反之,过线段AB之间任意一点C做直线L的垂线,垂足必定落在A'B'之间. 不难将此结论推广到n条线段的情况,假设存在一满足题意的直线L,则设点A为各个线段在L上投影的公共点,那…
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…
题目:POJ1269 题意:给你两条直线的坐标,判断两条直线是否共线.平行.相交,若相交,求出交点. 思路:直线相交判断.如果相交求交点. 首先先判断是否共线,之后判断是否平行,如果都不是就直接求交点了. #include <iostream> #include <string.h> #include <stdio.h> #include <algorithm> #include <math.h> #include <queue> #…
题目链接:http://poj.org/problem?id=1269 题面: Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersection because they are parallel, 2) interse…
题目链接: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 1269 Intersecting Lines Description We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a plane will intersect in one of three ways: 1) no intersection because they are parallel, 2) intersect in…