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. Android小玩意儿-- 从头开发一个正经的MusicPlayer(二)

    1·在Service中实例化MusicPlayer,实现对整个播放过程的控制 上一次做到了找到音乐数据,并封装成对象装在ArrayList里,把数据的信息显示在UI上.下面一个阶段就要开始真正的音乐播 ...

  2. Java集合类工具CollectionUtils的操作方法

    集合判断: 例1: 判断集合是否为空:CollectionUtils.isEmpty(null): trueCollectionUtils.isEmpty(new ArrayList()): true ...

  3. DROP DOMAIN - 删除一个用户定义的域

    SYNOPSIS DROP DOMAIN name [, ...] [ CASCADE | RESTRICT ] DESCRIPTION 描述 DROP DOMAIN 将从系统表中删除一个用户域. 只 ...

  4. vscode 快捷键 ctrl+shift+F 冲突了 解决办法

    vscode 快捷键 ctrl+shift+F 冲突了 解决办法 1.修复 搜狗输入法 ctrl+shift+F 中文 繁体简体的快捷键冲突 2.修复 微软输入法  ctrl+shift+F 冲突 ( ...

  5. Vue 2.0 右键菜单组件 Vue Context Menu

    Vue 2.0 右键菜单组件 Vue Context Menu https://juejin.im/entry/5976d14751882507db6e839c

  6. es 集群部署

    下载 [root@localhost ~]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.1 ...

  7. JVM的异常体系

    任何程序都追求正确有效的运行,除了保证我们代码尽可能的少出错之外,我们还要考虑如何有效的处理异常,一个良好的异常框架对于系统来说是至关重要的.最近在采集框架的时候系统的了解一边,收获颇多,特此记录相关 ...

  8. Codeforces Round #555 (Div. 3) 解题报告

    A.Reachable Numbers 题意: 给定操作f(x):将x加1,删去得到的数的所有末尾0,如f(10099)=10099+1=10100→1010→101.现在给定一个数n,对n进行无限次 ...

  9. 框架—Mybatis搭建

    1:导包 完整jar包:mybatis核心包+依赖包+mysqljdbc驱动包 2. 建库建表 3.实体类 4.映射文件 一般dao的包下 5.主配置文件(mybatisconfig.xml) 一般s ...

  10. js 漂浮广告

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...