http://poj.org/problem?id=1696

极角排序是就是字面上的意思   按照极角排序

题目大意:平面上有n个点然后有一只蚂蚁他只能沿着点向左走  求最多能做多少点

分析:  其实还不知道极角排序到底是什么,   但是又好像知道一点   必须一直排序  然后一直找到最左的点就行了

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<vector>
using namespace std;
#define INF 0xfffffff
#define ESP 1e-8
#define memset(a,b) memset(a,b,sizeof(a))
#define N 2100 struct Point
{
double x,y;
int index;
Point(double x=,double y=):x(x),y(y){}
Point operator - (const Point &temp)const{
return Point(x-temp.x,y-temp.y);
}
Point operator + (const Point &temp)const{
return Point(x+temp.x,y+temp.y);
}
int operator ^(const Point &temp)const{///求叉积
double t=(x*temp.y)-(y*temp.x);
if(t>ESP)
return ;
if(fabs(t)<ESP)
return ;
return -;
}
double operator * (const Point &temp)const{
return x*temp.x+y*temp.y;
}
bool operator == (const Point &temp)const{
return (x==temp.x)&&(y==temp.y);
}
}p[N]; double dist(Point a1,Point a2)
{
return sqrt((a1-a2)*(a1-a2));
}
int pos=; int cmp(Point a1,Point a2)
{
int t=(a1-p[pos])^(a2-p[pos]);
if(t==)
return dist(p[pos],a1) < dist(p[pos],a2);
else if(t<) return false;
else
return true;
} int main()
{
int T,n;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i=;i<n;i++)
{
scanf("%d %lf %lf",&p[i].index,&p[i].x,&p[i].y);
if(p[i].y<p[].y || (p[i].y==p[].y && p[i].x<p[].x))
swap(p[i],p[]);
}
pos=; for(int i=;i<n;i++)
{
sort(p+i,p+n,cmp);
pos++;
}
printf("%d",n);
for(int i=;i<n;i++)
printf(" %d",p[i].index);
printf("\n");
}
return ;
}

Space Ant--poj1696(极角排序)的更多相关文章

  1. poj 1696 Space Ant (极角排序)

    链接:http://poj.org/problem?id=1696 Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissi ...

  2. POJ 1696 Space Ant(极角排序)

    Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2489   Accepted: 1567 Descrip ...

  3. Space Ant(极角排序)

    Space Ant http://poj.org/problem?id=1696 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions ...

  4. POJ 1696 Space Ant 【极角排序】

    题意:平面上有n个点,一只蚂蚁从最左下角的点出发,只能往逆时针方向走,走过的路线不能交叉,问最多能经过多少个点. 思路:每次都尽量往最外边走,每选取一个点后对剩余的点进行极角排序.(n个点必定能走完, ...

  5. Space Ant---poj1696(极角排序)

    题目链接:http://poj.org/problem?id=1696 题意:给你n个点,然后我们用一条线把它们连起来,形成螺旋状: 首先找到左下方的一个点作为起点,然后以它为原点进行极角排序,找到极 ...

  6. poj 1696:Space Ant(计算几何,凸包变种,极角排序)

    Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2876   Accepted: 1839 Descrip ...

  7. poj1696 Space Ant【计算几何】

    含极角序排序模板.   Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5334   Accepted:  ...

  8. 二维坐标系极角排序的应用(POJ1696)

    Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3170   Accepted: 2029 Descrip ...

  9. POJ-1696 Space Ant 凸包版花式水过!

                                                         Space Ant 明天早上最后一科毛概了,竟然毫无复习之意,沉迷刷题无法自拔~~ 题意:说实 ...

  10. poj1696 Space Ant

    地址: 题目: Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4295   Accepted: 2697 ...

随机推荐

  1. C# string日期格式

    百分数格式应该用“p”这个参数. 格式 原始 数据 结 果 "{0:P}" 0.40 40% 数字 {0:N2} 12.36  数字 {0:N0} 13  货币 {0:c2} $1 ...

  2. Android(java)学习笔记180:多媒体之图形的变化处理

    1. 图形的缩放 (1)布局文件activity_main.xml如下: <LinearLayout xmlns:android="http://schemas.android.com ...

  3. 第1节 flume:10、flume的更多组件介绍

    作业:flume如何实现收集mysql的数据,没隔几秒钟,查看mysql中的数据是否有变化,一旦有变化,把数据拿过来,存到hdfs上. 需要使用custom source.可网上搜索,github上.

  4. [bzoj4899]记忆的轮廓 题解(毒瘤概率dp)

    题目背景 四次死亡轮回后,昴终于到达了贤者之塔,当代贤者夏乌拉一见到昴就上前抱住了昴“师傅!你终于回来了!你有着和师傅一样的魔女的余香,肯定是师傅”.众所周知,大贤者是嫉妒魔女沙提拉的老公,400年前 ...

  5. IIS实现HTTPS的主机名绑定

    默认情况下,IIS中HTTPS 绑定是无法指定主机名的解决办法:通过手工修改 IIS 配置来实现主机头绑定.打开如下位置的文件. C:\Windows\system32\inetsrv\config\ ...

  6. Ubuntu14.04环境下Qt5.5以上版本无法输入中文的解决教程

    1.前言 由于Qt5.4之后对之前的Qt5版本不再二进制兼容,所以网上很多简单的旧的办法已经失效了,所以本教程的办法是重新编译fcitx-qt5,生成最新的libfcitxplatforminputc ...

  7. mysql系列安装

    Mysql的5种安装方法:1.yum/rpm安装(适合要求不高,并发不大,公司内部,企业内部一些应用场景)2.编译安装(在线高并发业务)3.二进制安装(编译安装后,使用自带工具打包,然后拷贝到相同平台 ...

  8. php 链接 mongodb

    1.下载phpmongodb 驱动:https://s3.amazonaws.com/drivers.mongodb.org/php/index.html 2.Precompiled binaries ...

  9. 2. TypeScript笔记

    1. 安装node.js之后 需要测试npm命令 2.命令正常安装TypeScript 3.安装Egret egret 命令

  10. mac下出现xcrun: error导致git无法使用的解决办法

    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun BY  ...