URAL 1207 || Median on the Plane(将平面偶数点集均分
来源:互联网 发布:qq浏览器mac版什么内核 编辑:程序博客网 时间:2024/06/07 07:27
超级莫名其妙的一题,题目上面说点都坐标都是整数,叉积也只是坐标运算一下。可就是WA。我还以为是逆时针,顺时针什么鬼的出问题了。
改成double就好了。
找出两个点,这两个点的连线把点集平分为两块。
级角排序一下就好了,第一点和中间一点的连线就ok了。
顺时针,逆时针无所谓都一样~
#include<iostream>#include<cstdio>#include<algorithm>using namespace std;struct point{double x,y;int id;};point p[10000+5];const double eps = 1e-6;double cross(point a,point b){ return ( (a.x-p[0].x )*( b.y-p[0].y ) - (a.y-p[0].y )*(b.x-p[0].x ) );}bool angcmp( point a,point b){ return cross(a,b)>eps;}int main(){ int n; cin>>n; int t = 0; for( int i = 0 ;i<n; ++i) { scanf("%lf %lf",&p[i].x,&p[i].y); p[i].id = i+1; if( p[i].x<p[t].x || ( p[i].x==p[t].x && p[i].y < p[t].y)) t = i; } swap(p[0],p[t]); sort(p+1,p+n,angcmp); printf("%d %d\n",p[0].id,p[n/2].id); return 0;}
0 0
- URAL 1207 || Median on the Plane(将平面偶数点集均分
- timus 1207. Median on the Plane URAL 解题报告 计算几何 求两点把点均分
- URAL 1207 Median on the Plane
- URAL 1207 Median on the Plane(直线分割点集:极角排序)
- 计算几何 ural 1207 Median on the Plane
- ural 1207. Median on the Plane
- ural 1207. Median on the Plane(极角排序)
- Ural 1207. Median on the Plane(计算几何)
- Dividing The Plane 直线划分平面
- Codeforces 725B Food on the Plane
- codeforces 725B Food on the Plane
- CodeForces 725B Food on the Plane
- 平面直线切割问题 (LINES IN THE PLANE) 问题
- 平面方程(Plane Equation)
- 平面方程(Plane Equation)
- The Plane.
- Canada Cup 2016 B. Food on the Plane 找规律 .
- Codefroces 725B Food on the Plane【模拟】
- STL——sort 函数的使用方法
- BounceCusImageView
- Structs 2 注解校验
- js模拟Map
- 2-3工作日志
- URAL 1207 || Median on the Plane(将平面偶数点集均分
- Tzl_C#金字塔_virtual使用总结
- JUnit 总结
- C#读取XML文件——自定义类
- jQuery Validation插件onfocosout/onkeyup出错的解决方法[Uncaught TypeError: undefined is not a function中文资料不好找]
- 海思中fifo的使用及c语言中fifo的使用以及c中关于字符串的说明%s以及strlen注意问题
- OpenFire源码学习之十九:在openfire中使用redis插件(上)
- [HDU4927] Series 1 && 高精度+组合数
- 采药问题