题目大意:给一些散列点然后初始点是坐标最下面最左面的点,然后只能往左走,求出来最多可以经过多少个点,把序号输出出来。
 
分析:先求出来初始的点,然后不断排序找出来最近的凸点....复杂度是 n^2*log(n)。。。。不多点很少,所以随意玩。
 
代码如下:
=====================================================================================================================
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std; const int MAXN = ;
const double EPS = 1e-; struct Point
{
double x, y;
int id;
Point(double x=, double y=):x(x),y(y){}
Point operator - (const Point &tmp) const{
return Point(x-tmp.x, y-tmp.y);
}
double operator *(const Point &tmp) const{
return x*tmp.x + y*tmp.y;
}
double operator ^(const Point &tmp) const{
return x*tmp.y - y*tmp.x;
}
};
double Dist(Point a, Point b)
{
return sqrt((a-b)*(a-b));
}
Point p[MAXN];
int ki; bool cmp(Point a, Point b)
{
double t = (a-p[ki]) ^ (b-p[ki]); if(fabs(t) < EPS)
return Dist(p[ki], a) < Dist(p[ki], b);
return t > EPS;
} int main()
{
int T; scanf("%d", &T); while(T--)
{
int i, N; scanf("%d", &N); for(int i=; i<N; i++)
{
scanf("%d%lf%lf", &p[i].id, &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[]);
} ki = ; for(i=; i<N; i++, ki++)
{
sort(p+i, p+N, cmp);
} printf("%d", N);
for(i=; i<N; i++)
printf(" %d", p[i].id);
printf("\n");
} return ;
}

Space Ant - POJ 1696 (凸包)的更多相关文章

  1. POJ 1696 /// 凸包

    题目大意: 不能向左拐 不能重复走 就是求一个螺旋凸包 把已经是凸包内的点标记一下就行 因为凸包的性质 所有点都能走到 注意起点的选择 还有 反复求凸包的过程中边界的改变 #include <c ...

  2. 2018.07.04 POJ 1696 Space Ant(凸包卷包裹)

    Space Ant Time Limit: 1000MS Memory Limit: 10000K Description The most exciting space discovery occu ...

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

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

  4. POJ 1696 - Space Ant 凸包的变形

    Technorati Tags: POJ,计算几何,凸包 初学计算几何,引入polygon后的第一个挑战--凸包 此题可用凸包算法做,只要把压入凸包的点从原集合中排除即可,最终形成图形为螺旋线. 关于 ...

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

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

  6. POJ 1696 Space Ant 卷包裹法

    Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3316   Accepted: 2118 Descrip ...

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

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

  8. poj 1696 Space Ant(模拟+叉积)

    Space Ant Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3840   Accepted: 2397 Descrip ...

  9. POJ 1696 Space Ant(点积的应用)

    Space Ant 大意:有一仅仅蚂蚁,每次都仅仅向当前方向的左边走,问蚂蚁走遍全部的点的顺序输出.開始的点是纵坐标最小的那个点,開始的方向是開始点的x轴正方向. 思路:从開始点開始,每次找剩下的点中 ...

随机推荐

  1. JavaScript Invalid Date Verify

    if ( Object.prototype.toString.call(d) === "[object Date]" ) { // it is a date if ( isNaN( ...

  2. hdu 1573 A/B (扩展欧几里得)

    Problem Description 要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973)= 1). Input 数据的第一行 ...

  3. Savelog项目总结回忆

    Savelog项目的细节已经不太记得,感觉有些遥远,需要翻回旧的笔记本电脑或者是旧的笔记本. 概述: 本项目采用的Linux C,监听一个或多个特殊的端口,当其中一个端口有发起连接时就产生一个新的线程 ...

  4. PDF在xp或2003下正常在win7下乱码的问题

    1.先确定当前PDF文件需要字体(在PDF工具打开找到Font字体可以查看具体需要哪些字体). 2.网上下载或者在生成PDF的电脑上把老版本字体拷贝出来然后在win7下安装,当提示已经存在该字体时,直 ...

  5. python基础之列表常用操作及知识点小结

    列表(list) List(列表) 是 Python 中使用最频繁的数据类型.列表可以完成大多数集合类的数据结构实现.它支持字符,数字,字符串甚至可以包含列表(所谓嵌套).列表用[ ]标识,是pyth ...

  6. Global & Local Variable in Python

    Following code explain how 'global' works in the distinction of global variable and local variable. ...

  7. (MVC)验证用户是否登录 登录认证

    验证类 using System; using System.Collections.Generic; using System.Linq; using System.Web; using Syste ...

  8. 机务UI设计小节

    1.CSS样式 .header { background-color:#7A8692; color:White; height:30px; font-size:16px; width:100%; li ...

  9. Codeforces 731D Funny Game

    Description Once upon a time Petya and Gena gathered after another programming competition and decid ...

  10. Junit4学习笔记--方法的执行顺序

    package com.lt.Demo.TestDemo; import java.util.Arrays; import java.util.Collection; import org.junit ...