POJ 1696/hrbustoj 1318 几何 蛋疼的蚂蚁
来源:互联网 发布:c语言swich case 编辑:程序博客网 时间:2024/04/29 09:29
链接:POJ(英文):http://poj.org/problem?id=1696
hrbustoj(中文):http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1318
分析:逆时针极角排序(除了第一个点对y排序)
#include<iostream>#include<string>#include<cstring>#include<algorithm>#include<cstdio>#include<cmath>#include<iomanip>using namespace std;const int maxn=100000;struct point{ int u; int x, y; void read(){ cin>>u>>x>>y; }}f[105],cur;bool cmp_y(point a,point b){///对y排序 return a.y<b.y;}double cross(point p0,point p1,point p2){///两向量叉积 return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);}double dis(point a,point b){///两点距离 return sqrt(double((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)));}bool cmp(point a,point b){///极角排序 double ret = cross(cur,a,b); if(ret>0) return true; if(ret<0) return false; double x = dis(cur,a); double y = dis(cur,b); if(x<y) return true;///a靠得近 return false;}int main(){ int T; cin>>T; while(T--){ int n; cin>>n; for(int i=0;i<n;++i) f[i].read(); for(int i=0;i<n;++i){ if(!i)sort(f+i,f+n,cmp_y); else sort(f+i,f+n,cmp); cur = f[i]; if(!i)cout<<n; cout<<' '<<f[i].u; } cout<<endl; } return 0;}
- POJ 1696/hrbustoj 1318 几何 蛋疼的蚂蚁
- poj 1003坠落的蚂蚁
- poj 1852 隐形的蚂蚁---涵韶张
- 蚂蚁靠几何学识途
- POJ 1696 Space Ant 计算几何 叉积的应用
- POJ 1852 Ants 蚂蚁
- POJ 1852 蚂蚁
- poj 2674 Linear world 弹性碰撞 升级的蚂蚁
- poj 2957 计算几何向量的旋转
- POJ 1127 我的第一次计算几何
- poj 1696 Space Ant(计算几何)
- poj 1696 Space Ant 计算几何
- POJ 1696 Space Ant <计算几何>
- POJ-蚂蚁行军问题 1852
- POJ 1852 蚂蚁在杆上走
- poj 3046 数蚂蚁 dp
- 【模拟】【计算几何】[ZJOI2008][HYSBZ/BZOJ1033]杀蚂蚁antbuster
- 一只牛B的蚂蚁
- Setup VPN connection (Microsoft PPTP) for Ubuntu 12.04
- 如何在 ASM 存储中使用 Data Pump (expdp impdp)进行数据导出导入操作
- hash Babelfish poj 2503
- C/C++代码格式优化工具----astyle
- SEAndroid策略
- POJ 1696/hrbustoj 1318 几何 蛋疼的蚂蚁
- ASIHTTPRequest类库简介和使用说明
- java的2道逻辑算法题
- C#中Winform动态调用Webservice的方法
- C#转义字符
- zookeeper分布式配置管理
- hdu2041(超级楼梯)
- 清理Windows.edb文件释放C盘空间
- MMU工作原理,理解虚拟内存的奥秘