POJ - 2007 极角排序(Java 实现)】的更多相关文章

POJ 2007 将所有的点按逆时针输出 import java.io.*; import java.util.*; public class Main { static class Point implements Comparable<Point>{ double x, y; @Override public int compareTo(Point a) { return (int)cross(a); } public double cross(Point a){ return a.x*y…
题意: 给你n个点,这n个点可以构成一个多边形(但是不是按顺序给你的).原点(0,0)为起点,让你按顺序逆序输出所有点 题解: 就是凸包问题的极角排序 用double一直Wa,改了int就可以了 //原点(0,0)为起点,逆序输出多边形的点 #include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> #include<queue> #include<…
Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4970   Accepted: 3100 Description The most exciting space discovery occurred at the end of the 20th century. In 1999, scientists traced down an ant-like creature in the planet Y19…
#include<iostream> #include<cmath> #include<algorithm> using namespace std; double eps=1e-8; int sgn(double x) { if(fabs(x)<=eps)return 0; if(x<0)return -1; return 1; } struct Point { double x,y; int index; Point (){} Point(double…
Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3924   Accepted: 2457 Description The most exciting space discovery occurred at the end of the 20th century. In 1999, scientists traced down an ant-like creature in the planet Y19…
题目传送门 题意:裸的对原点的极角排序,凸包貌似不行. /************************************************ * Author :Running_Time * Created Time :2015/11/3 星期二 14:46:47 * File Name :POJ_2007.cpp ************************************************/ #include <cstdio> #include <al…
题目链接 题意 : 对输入的点极角排序 思路 : 极角排序方法 #include <iostream> #include <cmath> #include <stdio.h> #include <algorithm> using namespace std; struct point { double x,y; }p[],pp; double cross(point a,point b,point c) { return (a.x-c.x)*(b.y-c.y…
/** 极角排序输出,,, 主要atan2(y,x) 容易失精度,,用 bool cmp(point a,point b){ 5 if(cross(a-tmp,b-tmp)>0) 6 return 1; 7 if(cross(a-tmp,b-tmp)==0) 8 return length(a-tmp)<length(b-tmp); 9 return 0; 10 } **/ #include <iostream> #include <algorithm> #includ…
Scrambled Polygon Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 8636   Accepted: 4105 Description A closed polygon is a figure bounded by a finite number of line segments. The intersections of the bounding line segments are called the…
水题,根本不用凸包,就是一简单的极角排序. 叉乘<0,逆时针. #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <algorithm> using namespace std; const int maxn=55; struct point { double x,y; } p[maxn]; double cross(poi…
Scrambled Polygon Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 10841   Accepted: 5085 Description A closed polygon is a figure bounded by a finite number of line segments. The intersections of the bounding line segments are called the…
LINK 题意:给出一个简单多边形,按极角序输出其坐标. 思路:水题.对任意两点求叉积正负判断相对位置,为0则按长度排序 /** @Date : 2017-07-13 16:46:17 * @FileName: POJ 2007 凸包极角序.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.com/ * @Version : $Id$ */ #include <…
链接:http://poj.org/problem?id=1696 Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3077   Accepted: 1965 Description The most exciting space discovery occurred at the end of the 20th century. In 1999, scientists traced down an a…
从TLE的暴力枚举 到 13313MS的扫描线  再到 1297MS的简化后的扫描线,简直感觉要爽翻啦.然后满怀欣喜的去HDU交了一下,直接又回到了TLE.....泪流满面 虽说HDU的时限是2000MS 可是数据也忒强了点吧,真心给HDU跪了. 题意:给定平面上的N个点,属性分别标记为0和1,然后找一条直线,直线上的点全部溶解,一侧的1溶解,另一侧的0溶解.求出最多能溶解的点的个数. 思路:最直接的思路就是O(N^3)的暴力枚举,Discuss里面貌似有大牛过了,肯能是我太过暴力了吧,果断Tl…
题意:平面上有n个点,一只蚂蚁从最左下角的点出发,只能往逆时针方向走,走过的路线不能交叉,问最多能经过多少个点. 思路:每次都尽量往最外边走,每选取一个点后对剩余的点进行极角排序.(n个点必定能走完,这是凸包的性质决定的) #include<stdio.h> #include<string.h> #include<math.h> #include<iostream> #include<algorithm> using namespace std;…
Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2489   Accepted: 1567 Description The most exciting space discovery occurred at the end of the 20th century. In 1999, scientists traced down an ant-like creature in the planet Y19…
Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2876   Accepted: 1839 Description The most exciting space discovery occurred at the end of the 20th century. In 1999, scientists traced down an ant-like creature in the planet Y19…
Circle and Points Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 8346   Accepted: 2974 Case Time Limit: 2000MS Description You are given N points in the xy-plane. You have a circle of radius one and move it on the xy-plane, so as to enc…
题链: http://poj.org/problem?id=2007 题解: 计算几何,极角排序 按样例来说,应该就是要把凸包上的i点按 第三像限-第四像限-第一像限-第二像限 的顺序输出. 按 叉积 来排序的确可以A掉,但是显然有错呀. 比如这个例子: 0 0 -2 2 -1 -1 1 0 正确答案显然应该是: (0,0) (-2,2) (-1,-1) (1,0) 但是 用叉积 排序后却是这样: (0,0) (1,0) (-2,2) (-1,-1) (要用叉积排序的话,按道理来讲应该把像限分成…
题目链接:http://poj.org/problem?id=1696 题意:给你n个点,然后我们用一条线把它们连起来,形成螺旋状: 首先找到左下方的一个点作为起点,然后以它为原点进行极角排序,找到极角最小的那个点,如果又多个选距离近的,每次都这样循环找n个点即可; #include <stdio.h> #include <iostream> #include <algorithm> #include <string.h> using namespace s…
Space Ant http://poj.org/problem?id=1696 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5371   Accepted: 3343 Description The most exciting space discovery occurred at the end of the 20th century. In 1999, scientists traced down an ant-…
题目链接: How Many Triangles Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 570    Accepted Submission(s): 183 Problem Description Alice has n points in two-dimensional plane. She wants to know ho…
题目链接: Eureka Time Limit: 8000/4000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) Problem Description   Professor Zhang draws n points on the plane, which are conveniently labeled by 1,2,...,n. The i-th point is at (xi,yi). Professor…
题目链接: Fire-Control System Time Limit: 12000/5000 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others) Problem Description A new mighty weapon has just been developed, which is so powerful that it can attack a sector of indefinite size, as l…
http://poj.org/problem?id=1696 极角排序是就是字面上的意思   按照极角排序 题目大意:平面上有n个点然后有一只蚂蚁他只能沿着点向左走  求最多能做多少点 分析:  其实还不知道极角排序到底是什么,   但是又好像知道一点   必须一直排序  然后一直找到最左的点就行了 #include<stdio.h> #include<math.h> #include<algorithm> #include<iostream> #inclu…
Eureka Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2317    Accepted Submission(s): 678 Problem Description Professor Zhang draws n points on the plane, which are conveniently labeled by 1,2,…
原文链接:http://www.orlion.ga/193/ 由上图可看到希尔排序先约定一个间隔(图中是4),然后对0.4.8这个三个位置的数据进行插入排序,然后向右移一位对位置1.5.9进行插入排序按照此规律直到全部参与了排序.然后将间隔约定为4-1=3,然后继续进行如上的排序方法.具体过程如下: 9 1 2 3 0 4 5 7 6 8 Setp 1 经过间隔为4排序后变成 : 0 1 2 3 6 4 5 7 9 8 Setp 2 经过间隔为3排序后变成 : 0 1 2 3 6 4 5 7 9…
链接 卡了几天的破题,对于hdu的那份数据,这就一神题.. 借助极角排序,枚举以每一个点进行极角排序,然后构造两条扫描线,一个上面一个下面,两条同时走,把上线和下线的点以及上线左边的点分别统计出来,如下图 样例3: 假如现在以d为p[0],那么所有可能结果一定是他与其他点的连线所分割的平面,那么首先以de为上线,下线的角度为上线+pi,两条线始终维护着这样的关系.de的下一个点为f,di的下一个点为c ,比较一下两者需要转的角度,选取较小角度转,注意一下相同的时候的处理. #include <i…
1285 - Drawing Simple Polygon   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB Given set of points in the plane, your task is to draw a polygon using the points. You have to use all the points. To be more specific, each po…
Partial Tree Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/problem/C Description You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the mini…