Space Ant - POJ 1696 (凸包)
#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 (凸包)的更多相关文章
- POJ 1696 /// 凸包
题目大意: 不能向左拐 不能重复走 就是求一个螺旋凸包 把已经是凸包内的点标记一下就行 因为凸包的性质 所有点都能走到 注意起点的选择 还有 反复求凸包的过程中边界的改变 #include <c ...
- 2018.07.04 POJ 1696 Space Ant(凸包卷包裹)
Space Ant Time Limit: 1000MS Memory Limit: 10000K Description The most exciting space discovery occu ...
- poj 1696:Space Ant(计算几何,凸包变种,极角排序)
Space Ant Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2876 Accepted: 1839 Descrip ...
- POJ 1696 - Space Ant 凸包的变形
Technorati Tags: POJ,计算几何,凸包 初学计算几何,引入polygon后的第一个挑战--凸包 此题可用凸包算法做,只要把压入凸包的点从原集合中排除即可,最终形成图形为螺旋线. 关于 ...
- poj 1696 Space Ant (极角排序)
链接:http://poj.org/problem?id=1696 Space Ant Time Limit: 1000MS Memory Limit: 10000K Total Submissi ...
- POJ 1696 Space Ant 卷包裹法
Space Ant Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3316 Accepted: 2118 Descrip ...
- POJ 1696 Space Ant(极角排序)
Space Ant Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2489 Accepted: 1567 Descrip ...
- poj 1696 Space Ant(模拟+叉积)
Space Ant Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 3840 Accepted: 2397 Descrip ...
- POJ 1696 Space Ant(点积的应用)
Space Ant 大意:有一仅仅蚂蚁,每次都仅仅向当前方向的左边走,问蚂蚁走遍全部的点的顺序输出.開始的点是纵坐标最小的那个点,開始的方向是開始点的x轴正方向. 思路:从開始点開始,每次找剩下的点中 ...
随机推荐
- IOS LocationManager定位国内偏移,火星坐标(GCJ-02)解决方法
转载自:http://blog.csdn.net/swingpyzf/article/details/16972351 纠偏也可参考:http://www.2cto.com/kf/201310/253 ...
- jQuery AJAX load() 方法
jQuery load() 方法 jQuery load() 方法是简单但强大的 AJAX 方法. load() 方法从服务器加载数据,并把返回的数据放入被选元素中. 语法: $(selector). ...
- PHP发送AT指令
需求: 发送短信到用户输入手机, 要求可以自定义信息内容 问题: 没有电信猫, 使用免费api接口无法自定义短信内容 解决方案: 通过4G网卡, 接在服务器上, 通过AT指令操作网卡, 发送短信 查阅 ...
- jQuery分析(2) - $工厂函数分析
前言 从这节进入jQuery的世界,首先从jQuery的入口函数开始了解jQuery()或$是如何运作的,这里我给出了一个最小的例子来分析. 回忆 在进入分析代码前我们回想下jQuery的使用方法有哪 ...
- 打印出不同顺序的字符串&单引号和双引号的差异
发现一个很好玩的打印顺序 package com.liaojianya.chapter1; /** * This program demonstrates the string. * @author ...
- 冒泡排序(C++)
冒泡排序(C++) 冒泡排序(C++): 原理是临近的数字两两进行比较,按照从小到大或者从大到小的顺序进行交换, 这样一趟过去后,最大或最小的数字被交换到了最后一位, 然后再从头开始进行两两比较交换, ...
- Problem 1010 - 素数环问题
#include<iostream> #include<string> #include<algorithm> #include<vector> #in ...
- 正则过滤html标签
var html = "<p>好好学习,<br>天天向上</p>"; var re=/<[^>]+>/g; var text ...
- Bad owner or permissions on .ssh/config
Bad owner or permissions on $HOME/.ssh/config The ssh with RHEL 4 is a lot more anal about security ...
- jQuery插件综合应用(二)文字为主的页面
一.介绍 文字内容是每个网站都有的内容,网站在展示文字内容时,总是比图片.视频等富媒体内容要难一些,因为富媒体容易被用户接受.尤其是越多的文字内容越难以被用户通篇的阅读,跳跃式阅读往往是阅读的主要方式 ...