看了题目意思之后感觉哇,简单的 一批不就是判断线段之间有没有至少一个点嘛,,,,,结果wa到自闭,,

这个题的点有首先要根据点构造凸包,因为题目给的数据不一定是一个凸包,其次,我们在构造凸包极角排序的时候当点与左下角的点的角度大于90度的时候会把距离近的点排在前面,所以要改写极角排序的算法,,然后遍历每个点判断就行了,,多个点共线输出no,,然后傻逼的自己wa了一个晚上在于凸包都写不对,,哭

bool cmp(Point a,Point b)
{int ans=sgn((a-p[0])^(b-p[0]));if(ans==1)return true;else if(ans==0){if(sgn(atan2(a.y,a.x)-PI/2)>=0)return dist(a,p[0])>dist(b,p[0]);elsereturn dist(a,p[0])<dist(b,p[0]);}elsereturn false;
}
#include <iostream>
#include <cmath>
#include <algorithm>using namespace std;const double eps=1e-8;
const int maxn=40005;
const double PI=acos(-1.0);
int sgn(double x)
{if(fabs(x)<eps)return 0;if(x<0)return -1;elsereturn 1;
}
struct Point
{double x,y;Point(){}Point(double _x,double _y){x=_x;y=_y;}Point operator -(const Point &b)const{return Point(x-b.x,y-b.y);}double operator ^(const Point &b)const{return x*b.y-y*b.x;}double operator *(const Point &b)const{return x*b.x+y*b.y;}
};Point p[maxn];
int Stack[maxn];
int top=0;
int m;double dist(Point a,Point b)
{return sqrt((a-b)*(a-b));
}bool cmp(Point a,Point b)
{int ans=sgn((a-p[0])^(b-p[0]));if(ans==1)return true;else if(ans==0){if(sgn(atan2(a.y,a.x)-PI/2)>=0)return dist(a,p[0])>dist(b,p[0]);elsereturn dist(a,p[0])<dist(b,p[0]);}elsereturn false;
}void graham()
{for(int i=0;i<m;i++){if(p[i].y<p[0].y||(p[i].y==p[0].y&&p[i].x<p[0].x))swap(p[0],p[i]);}sort(p+1,p+m,cmp);if(m==1){Stack[0]=0;top=0;}else if(m==2){Stack[0]=0;Stack[1]=1;top=1;}else{Stack[0]=0;Stack[1]=1;top=1;for(int i=2;i<m;i++){while(top>0&&((p[Stack[top]]-p[Stack[top-1]])^(p[i]-p[Stack[top-1]]))<0)top--;top++;Stack[top]=i;}}
}bool vjudge()
{int cont=0;for(int i=1;i<=top;i++){if(((p[Stack[i-1]]-p[Stack[i]])^(p[Stack[(i+1)%(top+1)]]-p[Stack[i]]))!=0){cont++;}}if(cont==0)return false;cont=0;for(int i=1;i<=top;i++){if(((p[Stack[i-1]]-p[Stack[i]])^(p[Stack[(i+1)%(top+1)]]-p[Stack[i]]))!=0){if(cont==0)return false;cont=0;}elsecont++;/*if(i==top){if(cont==0)return false;}*/}return true;
}
int main()
{int n;cin>>n;while(n--){cin>>m;for(int i=0;i<m;i++)cin>>p[i].x>>p[i].y;if(m<6){cout<<"NO"<<endl;continue;}graham();/*for(int i=0;i<=top;i++){cout<<p[Stack[i]].x<<" "<<p[Stack[i]].y<<endl;}*/if(vjudge()==true){cout<<"YES"<<endl;}elsecout<<"NO"<<endl;}return 0;
}

Grandpa's Estate POJ - 1228(凸包极角序改写)相关推荐

  1. POJ 1228 Grandpa's Estate --深入理解凸包

    题意: 判断凸包是否稳定. 解法: 稳定凸包每条边上至少有三个点. 这题就在于求凸包的细节了,求凸包有两种算法: 1.基于水平序的Andrew算法 2.基于极角序的Graham算法 两种算法都有一个类 ...

  2. POJ 1228 —— “稳定”凸包

    POJ 1228 Grandpa's Estate 这是个好题目,同时也是个不和谐的题目(不和谐原因是题目出的存在漏洞,数据弱,而且有些条件没给清楚,为了一个SB错误无限WA之后,终于AC) 题意就废 ...

  3. Codeforces 70D 动态凸包 (极角排序 or 水平序)

    题目链接:http://codeforces.com/problemset/problem/70/D 本题关键:在log(n)的复杂度内判断点在凸包 或 把点插入凸包 判断:平衡树log(n)内选出点 ...

  4. poj 1228 Grandpa's Estate 给定了一个凸包的部分顶点和边上的点,判断是否能唯一确定一个凸包...

    题目来源: http://poj.org/problem?id=1228 题意:题目输入一个凸包上的点(没有凸包内部的点,要么是凸包顶点,要么是凸包边上的点),判断这个凸包是否唯一.所谓唯一就是判断能 ...

  5. poj 1228 Grandpa's Estate

    题目衔接:http://poj.org/problem?id=1228 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 168 ...

  6. Grandpa's Estate (凸包)

    传送门 Being the only living descendant of his grandfather, Kamran the Believer inherited all of the gr ...

  7. POJ1228 Grandpa's Estate

    题目: http://poj.org/problem?id=1228 题意: 给一堆点,是原凸包边上的点或内部的点(内部的点表明凸包被切割): 问能这些点能否唯一确定原来这个凸包 分析: 这是一个稳定 ...

  8. POJ - Wall(凸包周长)

    题目链接:http://poj.org/problem?id=1113 Time Limit: 1000MS Memory Limit: 10000K Description Once upon a ...

  9. poj 1584(凸包+点在凸多边形内+圆在凸多边形内)

    题意: 按照顺时针或逆时针方向输入一个n边形的顶点坐标集,先判断这个n边形是否为凸包. 再给定一个圆形(圆心坐标和半径),判断这个圆是否完全在n边形内部. 解题思路: 1.判断该多边形是否是凸包,由于 ...

最新文章

  1. Statement, PreparedStatement和CallableStatement的区别
  2. 【数据结构与算法】之深入解析“两数之和”的求解思路与算法示例
  3. linux下scp命令详解
  4. 大道至简第六章读后感
  5. 2019牛客第八场A All-one Matrices(单调栈)
  6. 编写干净的测试-被认为有害的新内容
  7. 计算机主机箱外部介绍图,电脑的主机结构是怎样的 电脑主机结构图【图文】...
  8. 英特尔杀入游戏显卡市场:支持光追和AI超分辨率,挑战AMD英伟达
  9. jsp iframe嵌入php,jsp中的iframe什么意思
  10. Codeforces Round #468 (Div. 2): E. Game with String
  11. Delphi源码排列
  12. 优炫数据库收到来自重庆市统计局的感谢信
  13. Mandriva linux 资源列表
  14. Xshell6复制粘贴快捷设置
  15. 公告栏模板php代码,destoon调用自定义模板及样式的公告栏_PHP教程
  16. 修改Visata下的无线网卡(Intel 5100 agn)Mac地址
  17. 家常菜做法:熬萝卜粉丝
  18. C#读取和写入文件(干货分享)
  19. 计算机数列类型,斐波那契(Fibonacci)数列的几种计算机解法
  20. vuetifyjs简介及其使用

热门文章

  1. emoji mysql 转 unicode_如何转义emoji表情,让它可以存入utf8的数据库?
  2. 西电高数上册期末考试题
  3. Shell - install
  4. 市场热度最高的手机开单库存管理软件
  5. 七个基本量纲_常用量纲
  6. 在洋葱(Onion)架构中实现领域驱动设计
  7. Android Studio学写英语听写APP(音乐播放器)一
  8. mplayer 视频播放器_如何全屏播放视频并使它与MPlayer循环播放?
  9. 解决Spring5源码编译各种Gradle报错问题
  10. android 8.0 l2tp问题,Android 8.0 的部分坑及对应解决方法