链接

贪心做法,没次找最外面的点,也就是相对前面那条线偏转角度最小的点,除第一个点需要找到最下面的点即Y坐标最小,其余的每次进行极角排序。

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 55
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
int o[];
struct Point
{
int x,y;
Point(double x=,double y=):x(x),y(y) {}
int id;
}p[N];
int cc;
typedef Point pointt;
pointt operator + (Point a,Point b)
{
return Point(a.x+b.x,a.y+b.y);
}
pointt operator - (Point a,Point b)
{
return Point(a.x-b.x,a.y-b.y);
}
double dis(Point a)
{
return sqrt(1.0*a.x*a.x+a.y*a.y);
}
int cross(Point a,Point b)
{
return a.x*b.y-a.y*b.x;
}
int mul(Point p0,Point p1,Point p2)
{
return cross(p1-p0,p2-p0);
} bool cmp(Point a,Point b)
{
if(mul(p[cc],a,b)==)
return dis(a-p[cc])<dis(b-p[]);
else
return mul(p[cc],a,b)>;
}
int main()
{
int t,i,n;
cin>>t;
while(t--)
{
scanf("%d",&n);
for(i = ; i <= n ;i++)
{
scanf("%d%d%d",&p[i].id,&p[i].x,&p[i].y);
}
int tmp = ;
for(i = ; i <= n; i++)
if(p[tmp].y>p[i].y)
{
tmp = i;
}
swap(p[],p[tmp]);
int g = ;
o[++g] = p[].id;
cc = ;
for(i = ;i <= n; i++)
{
sort(p+i,p+n+,cmp);
o[++g] = p[i].id;
cc = i;
}
printf("%d",g);
for(i = ;i <= g; i++)
printf(" %d",o[i]);
puts("");
}
return ;
}

poj1696Space Ant(逆时针螺旋形)的更多相关文章

  1. Codeforces Round #593 (Div. 2)D(螺旋形模拟)

    #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;vector<int>po[100 ...

  2. LintCode-381.螺旋矩阵 II

    螺旋矩阵 II 给你一个数n生成一个包含1-n^2的螺旋形矩阵 样例 n = 3 矩阵为 [     [ 1, 2, 3 ],     [ 8, 9, 4 ],     [ 7, 6, 5 ] ] 标 ...

  3. Spiral Matrix螺旋遍历矩阵

    假定有: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] 这样一个数组矩阵,现要求对其进行顺时针方向螺旋形从外至内地遍历,即输出: [1,2,3,6,9,8,7,4 ...

  4. AutoCAD中的螺旋究竟是什么螺旋?

    AutoCad从很早的时候就开始提供了螺旋线的功能,它的用法相对简单,非常适合用来对等距螺旋的理论进行演练. 选择螺旋线工具,首先画出一个基准圆,再向内(或向外)移动鼠标,拖出一个旋转3个周期的螺旋. ...

  5. 杭电ACM分类

    杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze ...

  6. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  7. 错觉-Info:让你难以置信的视错觉

    ylbtech-错觉-Info:让你难以置信的视错觉 1.返回顶部 1. 看下图:如果你看到舞者逆时针旋转说明你用左脑,如果看到顺时针旋转说明你用右脑思维. 据说这是耶鲁大学五年的研究成果.   下图 ...

  8. Atitit 常用比较复杂的图像滤镜 attilax大总结

    Atitit 常用比较复杂的图像滤镜 attilax大总结 像素画滤镜 水彩油画滤镜 素描滤镜 梦幻镜 特点是中央集焦,周围景物朦化微带光晕,使人产生如入梦境的感觉.常用于拍摄婚纱.明星照,也用于其它 ...

  9. 炉石传说 C# 设计文档(序)

    经过3个月的开发,有很多感触. 以前一直以为技术是开发成败的第一因素,现在发现,等到你代码写的时间够长,经验够丰富,什么功能都能随手完成,对于业务的分析能力变成了第一位. 炉石山寨版的BS版本用到的H ...

随机推荐

  1. 第十二届浙江省大学生程序设计大赛-Capture the Flag 分类: 比赛 2015-06-26 14:35 10人阅读 评论(0) 收藏

    Capture the Flag Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge In computer security, Ca ...

  2. 实现gabor filter的滤波

    实现gabor filter的滤波       图像纹理对于航空遥感图片.织物图案.复杂自然风景和动植物都适合.这里我采用遥感图片.织物图案和钢铁表面来做,并和canny图片进行一定的对比.     ...

  3. shell脚本判断文件类型

    转自:http://www.cnblogs.com/sunyubo/archive/2011/10/17/2282047.html 1. shell判断文件,目录是否存在或者具有权限 2. #!/bi ...

  4. Objective-C之null NaN undefined

    http://blog.csdn.net/siemenliu/article/details/6568306

  5. Spring.Net 技术简介 IOC and DI

    一 简单介绍            IOC 控制转移,就是将创建放到容器里,从而达到接耦合的目的,DI是 在容器创建对象的时候,DI读取配置文件,然后给对象赋默认值,两者一般结合使用,实现注入.   ...

  6. android导入项目出现style错误,menu错误

    android导入项目出现style错误,menu错误 style //查看 res/values/styles.xml 下的报错点. <style name="AppBaseThem ...

  7. duilib -- Label控件的bug(转载)

    转载:http://blog.csdn.net/rundll64/article/details/24823809?locationNum=6&fps=1 发现LabelUI的[属性列表.XM ...

  8. SqlSever基础 datepart 获取一个日期的月份

    镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...

  9. Linq实例

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs& ...

  10. Repeater导航菜单DataList产品展示

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JD.aspx.cs&quo ...