Poj 1228 Grandpa's estate (a portion of vertices on a given convex hull determine whether the convex hull is unique)

Source: Internet
Author: User

Question link: http://poj.org/problem? Id = 1228

This question is hard to think about. At first, it was always wa. Later, I didn't know where to change it.

From the example, we can see that the points of the convex Hill do not come in order, but are random points.

Then we create a convex hull on these points, so we cannot remove the edges when creating a convex hull.

That is, even the points that can be removed cannot be removed, that is, the traditional graphm method cannot be pre-selected.

If we want this convex hull to be unique after the end, we cannot add any point to the outside to make it grow.

A larger convex hull requires a vertex to have at least two vertices before or after it.

The edges can be collocated. Otherwise, you can insert a convex hull to the vertex!

# Include <iostream> # include <stdio. h> # include <string. h >#include <algorithm> # include <cmath> using namespace STD; # define EPS 1e-6 # define PI 3.14159265 struct point {Double X; Double Y;} po [1500], temp; int N, Pos; bool zero (double A) {return FABS (a) <EPS;} double DIS (point & A, point & B) // returns the square {return (. x-b.x) * (. x-b.x) +. y-b.y) * (. y-b.y);} double round SS (point & A, point & B, point & C) // calculate the X product of a B and A c {r Eturn (B. x-a.x) * (C. y-a.y)-(B. y-a.y) * (C. x-a.x);} int CMP (const void * a, const void * B) {int X; X = pair SS (po [0], * (point *), * (point *) B); If (zero (x) return DIS (po [0], * (point *) a) <DIS (po [0], * (point *) B )? -1: 1; return second SS (po [0], * (point *) A, * (point *) B)> 1e-8? -1: 1;} int Graham (INT num) {bool flag = true; int I, j, k = 2; po [num] = po [0]; // fangbiannum ++; for (I = 3; I <num; I ++) {While (Primary SS (po [k-1], po [K], po [I]) <-EPS) {k --;} po [++ K] = po [I]; // This loop ends, no more !} N = K; k = 0; for (I = 0; I <n; I ++) if (zero (distinct SS (po [I], po [I + 1], po [I + 2]) {k = 1; continue;} else {flag = false; If (k = 0) {printf ("NO \ n "); k = 10; return 0;} k = 0;} If (FLAG) {printf ("NO \ n"); Return 0;} If (K! = 10) printf ("Yes \ n"); Return 0;} int main () {int I, J, K, T; point my_temp, temp1; scanf ("% d", & T); While (t --) {scanf ("% d", & N); scanf ("% lf ", & po [0]. x, & po [0]. y); temp = po [0]; Pos = 0; for (I = 1; I <n; I ++) {scanf ("% lf ", & po [I]. x, & po [I]. y); If (po [I]. Y <temp. y) temp = po [I], Pos = I; If (po [I]. y = temp. Y & po [I]. x> temp. x) {temp1 = temp; temp = po [I], Pos = I;} temp = temp1; If (n <6) {printf ("NO \ n "); continue;} my_temp = po [0]; po [0] = po [POS]; po [POS] = my_temp; qsort (PO + 1, n-1, sizeof (po [0]), CMP); Graham (n);} return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.