http://poj.org/problem?id=1228

学长说这是稳定凸包,我感觉就是凸包嘛。

所谓稳定就是判断能不能在原有凸包上加点,得到一个更大的凸包,并且这个凸包包含原有凸包上的所有点。知道了这个东西就简单了,直接求出来凸包后,然后判断每条边上的点是否超过三点就行了。------无忧望月。

这道题的题也是看都看不懂,反正就是求凸包的每个边至少有三个点

还有如果是只有一条线的话输出NO

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<queue> using namespace std;
#define N 1005
#define pi acos(-1.0)
#define ESP 1e-8 int s[N]; struct Point
{
double x,y;
Point(double x=,double y=):x(x),y(y){}
Point operator - (const Point &temp)const
{
return Point(x-temp.x,y-temp.y);
}
Point operator + (const Point &temp)const
{
return Point(x+temp.x,y+temp.y);
}
bool operator == (const Point &temp)const
{
return (x==temp.x && y==temp.y);
}
double operator * (const Point &temp)const
{
return (x*temp.x+y*temp.y);
}
int operator ^ (const Point &temp)const{
double t=x*temp.y-y*temp.x;
if(t>ESP)
return ;
if(fabs(t)<ESP)
return ;
return -;
}
}p[N]; double dist(Point a,Point b)
{
return sqrt((a-b)*(a-b));
} int cmp(Point a1,Point a2)
{
int t=((a1-p[])^(a2-p[]));
if(t==)
return dist(a1,p[])<dist(a2,p[]);
else
return t>;
}
int top;
void Graham(int n)///求凸包
{
s[]=;
s[]=;
top=;
for(int i=;i<n;i++)
{
while(top> && ((p[i]-p[s[top]])^(p[s[top-]]-p[s[top]]))<=)
top--;
s[++top]=i;
}
} int main()
{ int T,n;
scanf("%d",&T);
while(T--)
{
int k=;
scanf("%d",&n);
for(int i=;i<n;i++)
{
scanf("%lf %lf",&p[i].x,&p[i].y);
if(p[i].y<p[k].y || (p[i].y==p[k].y && p[i].x<p[k].x))
k=i;
}
swap(p[],p[k]);
sort(p+,p+n,cmp);
Graham(n);
s[++top]=s[];
int flag=;
for(int i=;i<=top;i++)
{
int ans=;
for(int j=;j<n;j++)
{
if(((p[j]-p[s[i]]) ^ (p[s[i-]]-p[s[i]]))==)
ans++;
}
if(ans<)
{
flag=;
break;
}
}
if(flag== && top>=)
printf("YES\n");
else
printf("NO\n");
}
return ;
}

Grandpa's Estate---POJ1228(凸包)的更多相关文章

  1. POJ1228 Grandpa's Estate 稳定凸包

    POJ1228 转自http://www.cnblogs.com/xdruid/archive/2012/06/20/2555536.html   这道题算是很好的一道凸包的题吧,做完后会加深对凸包的 ...

  2. 【POJ】1228 Grandpa's Estate(凸包)

    http://poj.org/problem?id=1228 随便看看就能发现,凸包上的每条边必须满足,有相邻的边和它斜率相同(即共线或凸包上每个点必须一定在三点共线上) 然后愉快敲完凸包+斜率判定, ...

  3. POJ 1228 Grandpa's Estate(凸包唯一性判断)

    Description Being the only living descendant of his grandfather, Kamran the Believer inherited all o ...

  4. POJ 1228 - Grandpa's Estate 稳定凸包

    稳定凸包问题 要求每条边上至少有三个点,且对凸包上点数为1,2时要特判 巨坑无比,调了很长时间= = //POJ 1228 //稳定凸包问题,等价于每条边上至少有三个点,但对m = 1(点)和m = ...

  5. POJ 1228 Grandpa's Estate(凸包)

    Grandpa's Estate Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 11289   Accepted: 3117 ...

  6. poj1228 Grandpa's Estate

    地址:http://poj.org/problem?id=1228 题目: Grandpa's Estate Time Limit: 1000MS   Memory Limit: 10000K Tot ...

  7. POJ1228:Grandpa's Estate(给定一些点,问是否可以确定一个凸包)

    Being the only living descendant of his grandfather, Kamran the Believer inherited all of the grandp ...

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

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

  9. 【POJ 1228】Grandpa's Estate 凸包

    找到凸包后暴力枚举边进行$check$,注意凸包是一条线(或者说两条线)的情况要输出$NO$ #include<cmath> #include<cstdio> #include ...

  10. 简单几何(求凸包点数) POJ 1228 Grandpa's Estate

    题目传送门 题意:判断一些点的凸包能否唯一确定 分析:如果凸包边上没有其他点,那么边想象成橡皮筋,可以往外拖动,这不是唯一确定的.还有求凸包的点数<=2的情况一定不能确定. /********* ...

随机推荐

  1. java 线程的优先级

    //线程的优先级 //线程1 class xc1 implements Runnable{ public void run(){ for(int i=0;i<20;i++){ System.ou ...

  2. gcc-常见命令和错误

      一:编译过程的4个阶段:预处理,编译,汇编,链接; 1:最常用的方式 gcc hello.c -o hello 2:预处理后停止编译 gcc -E hello.c -o hello.i(.i通常为 ...

  3. inline-block和block的区别

    <html> <head> <style> body,ul,li,span{padding:0px;margin:0px;} </style> < ...

  4. Windows Server 2003服务器无法下载.exe文件的解决方法

    今天架设了一台Windows Server 2003的网站服务器,发现打开网页后无法下载网站中的.exe文件,经过研究问题得以解决,拿来做个备忘. 解决方法非常简单,只需要在IIS中,将网站属性里的执 ...

  5. js实现一套代码来控制所有的运动,图片的淡入淡出,winth,height的变宽

    介绍了那么多运动,這次一套代码实现所有运动 1.html代码和css代码,只是定义一个div <style> div{ width:200px; height:200px; margin: ...

  6. Mysql中将日期转化为毫秒

    一:将毫秒值转化为指定日期格式 使用MYSQL自带的函数FROM_UNIXTIME(unix_timestamp,format). 举例: select FROM_UNIXTIME(136417651 ...

  7. mysql之预处理语句prepare、execute、deallocate

    预制语句的SQL语法基于三个SQL语句: PREPARE stmt_name FROM preparable_stmt; EXECUTE stmt_name [USING @var_name [, @ ...

  8. oracle中SQL根据生日日期查询年龄的方法

    方法:SELECT Trunc(MONTHS_BETWEEN(SYSDATE,BIRTH_DATE)/12) FROM 某表 Trunc函数在这里对带有小数位数的数字取整数部分: SYSDATE为or ...

  9. IOleItemContainer的接口定义

      IOleItemContainer的接口定义

  10. VC++ MFC 按钮的全部样式Style

    Button Styles BS_3STATE 与复选框一样本样式按钮可被单击变暗.变暗状态通常用于指示本样式的按键正处于禁用状态. BS_AUTO3STATE   与三状态的复选框一样当用户选中它本 ...