题目大意:给一些散列点然后初始点是坐标最下面最左面的点,然后只能往左走,求出来最多可以经过多少个点,把序号输出出来。
 
分析:先求出来初始的点,然后不断排序找出来最近的凸点....复杂度是 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. tableview 在ios8上面分割线不全的问题

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath ...

  2. 判断ios是app第一次启动

    首次运行的应用程序加入一些help 或者 宣传动画 现在变的很重要了. 一个有用的例子是发送一个分析实例.这可能是一个很好的方法来确定有多少人下载实用应用程序.有人会说:“但是,嘿,苹果AppStor ...

  3. Lucene初步搜索

    Lucene在创立索引后,要进行搜索查询 搜索大概需要5部, 1,读取索引. 2,查询索引. 3,匹配数据. 4,封装匹配结果. 5,获取需要的值. 语言表达能力不好,大概就是分着几部吧. /** * ...

  4. YII CRUD 例子

    < ? php class PostTest extends CDbTestCase{ public $ fixtures = array ( 'posts' = > 'Post' , ' ...

  5. 24种设计模式--装饰模式【Decorator Pattern】

    装饰模式在中国使用的那实在是多,中国的文化是中庸文化,说话或做事情都不能太直接,需要有技巧的,比如说话吧,你要批评一个人,你不能一上来就说你这个做的不对,那个做的不对,你要先肯定他的成绩,表扬一下优点 ...

  6. 速卖通api--发起授权

    <? $reqURL_onLine = "https://gw.api.alibaba.com/openapi/http/1/system.oauth2/getToken/494739 ...

  7. cookie : 存储数据

    cookie : 存储数据,当用户访问了某个网站(网页)的时候,我们就可以通过cookie来像访问者电脑上存储数据 1.不同的浏览器存放的cookie位置不一样,也是不能通用的 2.cookie的存储 ...

  8. C# Delegate 异步调用

    namespace ConsoleApplication22 { /// /// 异步操作 /// /// /// /// //internal Func<int,int,int> int ...

  9. 关于谷歌浏览器下自动填写密码的bug

    有的时候我们需要用到h5中input的新类型,type=password 这个可以很好的将输入的内容变成圆点,但是这样做也有一个小bug就是在某些我们不希望自动保存密码的页面中,也会出现浏览器自动帮我 ...

  10. WPFDispatcher示例

    Dispatcher 类提供用于管理线程工作项队列的服务. 效果演示: <Window x:Class="WPF之Dispatcher对象.MainWindow" xmlns ...