Scrambled Polygon
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 7805   Accepted: 3712

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 vertices of the polygon. When one starts at any vertex of a closed polygon and traverses each bounding line segment exactly once, one comes back to the starting vertex.

A closed polygon is called convex if the line segment joining any two points of the polygon lies in the polygon. Figure 1 shows a closed polygon which is convex and one which is not convex. (Informally, a closed polygon is convex if its border doesn't have any "dents".) 

The subject of this problem is a closed convex polygon in the coordinate plane, one of whose vertices is the origin (x = 0, y = 0). Figure 2 shows an example. Such a polygon will have two properties significant for this problem.

The first property is that the vertices of the polygon will be confined to three or fewer of the four quadrants of the coordinate plane. In the example shown in Figure 2, none of the vertices are in the second quadrant (where x < 0, y > 0).

To describe the second property, suppose you "take a trip" around the polygon: start at (0, 0), visit all other vertices exactly once, and arrive at (0, 0). As you visit each vertex (other than (0, 0)), draw the diagonal that connects the current vertex with (0, 0), and calculate the slope of this diagonal. Then, within each quadrant, the slopes of these diagonals will form a decreasing or increasing sequence of numbers, i.e., they will be sorted. Figure 3 illustrates this point. 
 

Input

The input lists the vertices of a closed convex polygon in the plane. The number of lines in the input will be at least three but no more than 50. Each line contains the x and y coordinates of one vertex. Each x and y coordinate is an integer in the range -999..999. The vertex on the first line of the input file will be the origin, i.e., x = 0 and y = 0. Otherwise, the vertices may be in a scrambled order. Except for the origin, no vertex will be on the x-axis or the y-axis. No three vertices are colinear.

Output

The output lists the vertices of the given polygon, one vertex per line. Each vertex from the input appears exactly once in the output. The origin (0,0) is the vertex on the first line of the output. The order of vertices in the output will determine a trip taken along the polygon's border, in the counterclockwise direction. The output format for each vertex is (x,y) as shown below.

Sample Input

0 0
70 -50
60 30
-30 -50
80 20
50 -60
90 -20
-30 -40
-10 -60
90 10

Sample Output

(0,0)
(-30,-40)
(-30,-50)
(-10,-60)
(50,-60)
(70,-50)
(90,-20)
(90,10)
(80,20)
(60,30)
题意:就是给你一些点,起点已经告诉你是(0,0),让输出这个多边形,斜率从小到大表示;
题解:排下序就好了,注意把除变成乘。。。
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
const int INF=0x3f3f3f3f;
#define mem(x,y) memset(x,y,sizeof(x))
#define SI(x) scanf("%d",&x);
struct Node{
int x,y;
friend bool operator < (Node a,Node b){
if(a.y*b.x<b.y*a.x)return true;
else return false;
}
}dt[100010];
int main(){
int k=0;
while(~scanf("%d%d",&dt[k].x,&dt[k].y))k++;
sort(dt+1,dt+k);
for(int i=0;i<k;i++)printf("(%d,%d)\n",dt[i].x,dt[i].y);
return 0;
}

  

  

Scrambled Polygon(凸多边形,斜率)的更多相关文章

  1. Scrambled Polygon(斜率排序)

    Scrambled Polygon Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 7799   Accepted: 3707 ...

  2. POJ 2007 Scrambled Polygon 凸包

    Scrambled Polygon Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 7214   Accepted: 3445 ...

  3. POJ 2007 Scrambled Polygon [凸包 极角排序]

    Scrambled Polygon Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 8636   Accepted: 4105 ...

  4. [LeetCode] Convex Polygon 凸多边形

    Given a list of points that form a polygon when joined sequentially, find if this polygon is convex ...

  5. poj 2007 Scrambled Polygon(极角排序)

    http://poj.org/problem?id=2007 Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6701   A ...

  6. 简单几何(极角排序) POJ 2007 Scrambled Polygon

    题目传送门 题意:裸的对原点的极角排序,凸包貌似不行. /************************************************ * Author :Running_Time ...

  7. POJ 2007 Scrambled Polygon (简单极角排序)

    题目链接 题意 : 对输入的点极角排序 思路 : 极角排序方法 #include <iostream> #include <cmath> #include <stdio. ...

  8. Scrambled Polygon - POJ 2007(求凸包)

    给一些点,这些点都是一个凸包上的顶点,以第一个点为起点顺时针把别的点拍排一下序列. 分析:最简单的极坐标排序了..................... 代码如下: ----------------- ...

  9. poj 2007 Scrambled Polygon 极角排序

    /** 极角排序输出,,, 主要atan2(y,x) 容易失精度,,用 bool cmp(point a,point b){ 5 if(cross(a-tmp,b-tmp)>0) 6 retur ...

随机推荐

  1. 使用VisualStudio发布ASP.NET网站

    1.右击网站点击“发布网站” 2.选择或导入发布配置文件.→新建配置文件. 3.输入名称test.→点击确定. 4.发布方法选择文件系统. 5.选择目标位置.→点击下一步 6.文件发布选项选择三个选项 ...

  2. Streams Studio配置Build options

    Defining build options You can change the build options of the internal builder for building an SPL ...

  3. codeforces 510E. Fox And Dinner 网络流

    题目链接 给出n个人, 以及每个人的值, 要求他们坐在一些桌子上面, 每个桌子如果有人坐, 就必须做3个人以上. 并且相邻的两个人的值加起来必须是素数.每个人的值都>=2. 由大于等于2这个条件 ...

  4. eclipse 搭建Robotium环境--apk 环境搭建

    1.配置好android sdk ,java环境 2.重新签名apk文件 在用户目录下,会有一个.android的目录,把re-sign.jar放在该目录下.执行命令 java -jar re-sig ...

  5. nyist 220 推桌子

    题目链接:推桌子 题目意思:给你一些操作,将S出的桌子推到L出,但是这个过道有时会被占用,推一次是10min,不影响的操作可以同时开始,并且只记一次. 思路:贪心,首先按照S从小到大排序,决策:从第一 ...

  6. jQuery 插件入门

    先看http://www.cnblogs.com/lideng/p/3605551.html http://www.cnblogs.com/xcj26/p/3345556.html (非常细致  很多 ...

  7. 实验时css层叠样式表不更新的情况

    自定义了CSS的样式,希望在页面中起作用.因为MVC中Views/Shared/_Layout.cshtml是所有视图的公共文件,如下: <!DOCTYPE html> <html& ...

  8. Scale-up(纵向扩展) vs Scale-out(横向扩展)

    转载:http://wuaner.iteye.com/blog/1843799 http://www.javaworld.com/article/2077780/java-web-developmen ...

  9. 操作native window的QxtWindowSystem (好像是一个IM的一部分)

    http://libqxt.bitbucket.org/doc/0.6/qxtwindowsystem.html https://github.com/psi-plus/plugins/blob/ma ...

  10. 获取ubuntu 的root密码,告别sudo

    刚刚开始使用ubuntu的朋友可能知道一个提权命令    sudo 如果你接触过其他的Linux系统的话,你会知道  linux系统有一个最高权限   root.一般用su root,然后输入密码就可 ...