POJ 1228 Grandpa's Estate
来源:互联网 发布:怎么重新淘宝开店认证 编辑:程序博客网 时间:2024/06/06 15:00
第一次做凸包,2Y,^ ^
#include<iostream>#include<string>#include<cstring>#include<cmath>#include<cstdio>using namespace std;int n,pos;struct point{ int x,y;}p[1010];const int inf=0x7fffffff;int mult(point a,point b,point c){ if((a.x-b.x)*(a.y-c.y)<(a.y-b.y)*(a.x-c.x)) return 1; if((a.x-b.x)*(a.y-c.y)==(a.y-b.y)*(a.x-c.x)) return -1; return 0;}bool dist(point a,point b,point c){ return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)>(a.x-c.x)*(a.x-c.x)+(a.y-c.y)*(a.y-c.y);}bool jarvis(point pp){ int i; point tmp=p[pos]; bool flag=false; for(i=0;i<n;i++) // if(!vis[i]) { int judge=mult(pp,tmp,p[i]); if(judge==1) { flag=false; tmp=p[i]; } else if(judge==-1) { flag=true; if(dist(pp,p[i],tmp)) tmp=p[i]; } } if(!flag) return false; if(p[pos].x==tmp.x&&p[pos].y==tmp.y) return true; jarvis(tmp);}int main(){ int t,i,minx,miny; // freopen("sample.txt","r",stdin); cin>>t; while(t--) { minx=miny=inf; cin>>n; for(i=0;i<n;i++) { cin>>p[i].x>>p[i].y; if(p[i].x<minx) { pos=i; minx=p[i].x; miny=p[i].y; } else if(p[i].x==minx&&miny>p[i].y) { pos=i; miny=p[i].y; } } if(n>=6&&jarvis(p[pos])) cout<<"YES"<<endl; else cout<<"NO"<<endl; }return 0;}
- poj 1228 Grandpa's Estate
- POJ 1228 Grandpa's Estate
- POJ 1228 Grandpa's Estate
- POJ 1228 Grandpa's Estate
- POJ 1228 Grandpa's Estate
- POJ 1228 Grandpa's Estate
- POJ 1228 Grandpa's Estate
- poj - 1228 - Grandpa's Estate
- poj 1228 Grandpa's Estate
- POJ 1228 Grandpa's Estate
- POJ 1228 Grandpa's Estate -
- POJ 1228 Grandpa's Estate
- poj 1228 Grandpa's Estate
- POJ-1228 Grandpa's Estate
- POJ 1228 Grandpa's Estate
- poj Grandpa's Estate
- Grandpa's Estate POJ
- zoj 1377 || poj 1228 Grandpa's Estate
- Code forces 200C---Football Championship
- XAMPP安装后启动Apache的Busy解决方法
- Android Camera
- 中兴执行副总裁何士友:未来手机OS只有三家
- ORM
- POJ 1228 Grandpa's Estate
- 使用hibernate的聚集函数
- 复习总结(API和集合)
- 编译notepad++的错误解决
- Unknown action button_field_action_hello_world.
- IEnumerable IEnumerato foreach
- Code forces 103A---Testing Pants for Sadness
- HDU 3549 Flow Problem 解题报告(EK)算法
- dsm