POJ 1228 判断原始凸包是否唯一
来源:互联网 发布:手机版仓库进销存软件 编辑:程序博客网 时间:2024/06/18 00:19
题意:给出一个去掉几个点后的凸包,判断剩下的几个点组成的新凸包是不是原来的那个凸包。
分析:只要 新凸包的每条边上有3个或3个以上的点时,凸包就是原来那个凸包,
否则凸包不是原来那个凸包。 很好理解的,不是很难想到。
#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;#define eps 1e-8struct point {int x, y;bool operator < (const point &t) const { //重载<符号return y < t.y || (y == t.y && x < t.x);}} p[1009];int cross(point o, point a, point b) {return (a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x);}bool dotOnSeg(point a, point b, point c) { // 判断 点c是否在线段ab上return !cross(a, b, c) && (c.x - b.x) * (c.x - a.x) <= 0&& (c.y-b.y)*(c.y-a.y) <= 0;}int n, m;point st[1009];void graham(point *p, int n, point *st, int &m) {//凸包,起点和终点是同一个点int i;sort(p, p + n);m = 0;for(i = 2; i < n; i++) {while(m >= 2 && cross(st[m-2], st[m-1], p[i]) <= 0)m--;st[m++] = p[i];}int t = m+1;for(i = n - 2; i >= 0; i--) {while(m >= t && cross(st[m-2], st[m-1], p[i]) <= 0)m--;st[m++] = p[i];}}bool judge(point *p, int n, point *st, int m) {if(n <= 5 || m == 1)return 0;int i, j;for(i = 0; i < m-1; i++) {int cnt = 0;for(j = 0; j < n; j++)if(dotOnSeg(st[i], st[i + 1], p[j]))cnt++;if(cnt < 3)return 0;}return 1;}int main() {int i, j, cas;scanf("%d", &cas);while(cas--) {scanf("%d", &n);for(i = 0; i < n; i++)scanf("%d%d", &p[i].x, &p[i].y);graham(p, n, st, m);puts(judge(p, n, st, m) ? "YES" : "NO");}return 0;}
- POJ 1228 判断原始凸包是否唯一
- poj-1228 Grandpa's Estate(判断凸包是否唯一)
- POJ 1228 Grandpa's Estate(给定凸包上的一部分顶点 判断表示的凸包是否唯一)
- poj 1228 Grandpa's Estate 给定了一个凸包的部分顶点和边上的点,判断是否能唯一确定一个凸包
- POJ 1228 Grandpa's Estate(判断是否稳定凸包)
- POJ 1679 判断最小树是否唯一
- POJ 1679 判断最小树是否唯一
- poj 1228 判唯一凸包
- poj 1679 判断最小生成树是否唯一
- POJ 1679 判断最小生成树是否唯一
- poj 1679 判断最小生成树是否唯一
- POJ 1679 判断最小生成树是否唯一
- poj 1679 判断最小生成树是否唯一(kruskal)
- POJ--1679--The Unique MST【判断MST是否唯一】
- poj 1679 判断最小生成树是否唯一
- POJ 1679 The Unique MST(判断MST是否唯一)
- POJ --- 1679 【判断最小生成树是否唯一】
- 判断MST是否唯一
- POJ 2074 Line of Sight 直线交
- 瓷砖覆盖问题
- POJ 2007 Scrambled Polygon 极角排序
- POJ 1873 The Fortified Forest 二进制枚举 + 凸包 (final水题)
- oracle创建表空间和用户,删除表空间、用户
- POJ 1228 判断原始凸包是否唯一
- POJ 3348 Cows 凸包 + 多边形面积公式
- POJ 1654 Area 多边形面积
- 0829
- POJ 2954 Triangle pick公式
- POJ 半平面交 模板题 三枚
- POJ 1279 Art Gallery 半平面交 + 多边形面积
- POJ 3525 Most Distant Point from the Sea 半平面交 +二分
- POJ 3384 Feng Shui 半平面交