poj1228
来源:互联网 发布:教学白板软件多少钱 编辑:程序博客网 时间:2024/06/05 00:58
//赚点积分下资源
#include <iostream>#include <algorithm>#include <cmath>using namespace std;#define esp 1e-8struct upoint{double x;double y;}Point[1003];int stack[1003];int N;double Xmult(upoint a,upoint b,upoint c){return (a.x-c.x)*(b.y-c.y)-(b.x-c.x)*(a.y-c.y);}double dis(upoint a,upoint b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}bool dayu(double a,double b){return a-esp>b;}bool cmp(upoint a,upoint b){return a.x<b.x||(a.x==b.x&&a.y<b.y);}int tubao(){sort(Point,Point+N,cmp);int top=1;for(int i=0;i<3;i++)stack[i]=i;for(int i=2;i<N;i++){while(top){double x=Xmult(Point[i],Point[stack[top]],Point[stack[top-1]]);double d1=dis(Point[i],Point[stack[top-1]]);double d2=dis(Point[stack[top]],Point[stack[top-1]]);if(x>0)top--;else if(x==0&&dayu(d1,d2))top--;else break;}stack[++top]=i;}int t=top;stack[++top]=N-2;for(int i=N-3;i>=0;i--){while(top>t){double x=Xmult(Point[i],Point[stack[top]],Point[stack[top-1]]);double d1=dis(Point[i],Point[stack[top-1]]);double d2=dis(Point[stack[top]],Point[stack[top-1]]);if(x>0)top--;else if(x==0&&dayu(d1,d2))top--;else break;}stack[++top]=i;}return top;}bool manzu(int i,int j,int k){return 0==(Point[i].x-Point[k].x)*(Point[j].y-Point[k].y)-(Point[i].y-Point[k].y)*(Point[j].x-Point[k].x);}bool nothave(int i,int j){for(int k=0;k<N;k++)if(k!=i&&k!=j){if(manzu(i,j,k))return false;}return true;}int main(){int kase;cin>>kase;while(kase--){cin>>N;for(int i=0;i<N;i++){int a,b;cin>>a>>b;Point[i].x=1.0*a;Point[i].y=1.0*b;}if(N<=5){cout<<"NO\n";continue;}int top=tubao();if(top<3){cout<<"NO\n";continue;}int yes=1;for(int i=1;i<top;i++){int j=i-1;if(nothave(stack[i],stack[j])){yes=0;break;}}if(nothave(stack[top-1],stack[0]))yes=0;if(yes)cout<<"YES\n";else cout<<"NO\n";}return 0;}//0 1 0 2 0 3 0 4 0 5 NO
//N<=5 NO
//TOP<3 NO~
0 0
- poj1228
- POJ1228
- poj1228
- poj1228
- POJ1228 Grandpa's Estate
- Poj1228(稳定凸包)
- poj1228 - Grandpa's Estate
- POJ1228--Grandpa's Estate
- POJ1228-Grandpa's Estate
- Poj1228 Grandpa's Estate
- POJ1228(稳定凸包问题)
- POJ1228(稳定凸包问题)
- poj1228 [ SDOI2009 ] --稳定凸包
- POJ1228 Grandpa's Estate 还是凸包
- 凸包,有利于理解凸包极角排序poj1228
- POJ1228-Grandpa's Estate(凸包)
- poj1228 (判断凸包的完整性)
- poj1228 Grandpa's Estate 凸包
- eclipse/myeclipse下的较为不错的插件分享
- 寻找素数对
- PostgreSQL事务隔离级别
- 笔记杂项
- Fedora 中使用逻辑卷管理器调整LVM分区大小
- poj1228
- 学习zigbee入门-3
- 25条提高iOS App性能的技巧和诀窍
- 关于C指针的那些事
- hdu 2565 放大的X
- ComboBoxPropertyDescriptor 中使用枚举类型
- 学习zigbee入门-4
- wpa_supplicant--内部结构分析
- Android中关于inflate