Poj 3335 rotating scoreboard

Source: Internet
Author: User

Same as poj3130

Solution: Same as poj3130


Poj3130 solution Report: click here


Note: The order of points given by the two questions is different. Do not copy templates all the time (I won't tell you that I did it ).


The following code is used:

# Include <set> # include <map> # include <queue> # include <math. h> # include <vector> # include <string> # include <stdio. h> # include <string. h> # include <stdlib. h >#include <iostream> # include <algorithm> # define EPS 1e-8 # define PI ACOs (-1.0) # define INF 107374182 # define inf64 1152921504606846976 # define LC l, m, tr <1 # define RC m + 1, R, TR <1 | 1 # define zero (a) FABS (a) <EPS # define iabs (X) (x)> 0? (X):-(x) # define clear1 (A, X, size) memset (A, X, sizeof (A [0]) * (size )) # define clearall (A, x) memset (A, X, sizeof (A) # define memcopy1 (A, X, size) memcpy (A, X, sizeof (X [0]) * (size) # define memcopyall (A, x) memcpy (A, X, sizeof (x) # define max (x, y) (x)> (y ))? (X): (y) # define min (x, y) (x) <(y ))? (X): (y) using namespace STD; const int maxn = 55; int DQ [maxn], top, bot, Pn, order [maxn], ln; struct point {Double X, Y;} p [maxn]; struct line {point a, B; double angle;} l [maxn]; int dblcmp (Double K) {If (FABS (k) <EPS) return 0; return K> 0? 1:-1;} Double Multi (point P0, Point P1, point P2) {return (p1.x-Snapshot X) * (p2.y-Snapshot y)-(p1.y-Snapshot y) * (p2.x-0000x);} bool CMP (int u, int v) {int d = dblcmp (L [u]. angle-L [v]. angle); If (! D) return dblcmp (multi (L [u]. a, L [v]. a, L [v]. b) <0; // the left half of the orientation is divided into half plane, less than 0. Return d <0;} void getintersect (line L1, line L2, point & P) {double dot1, dot2; dot1 = multi (l2.a, l1. B, l1.a); dot2 = multi (l1. B, l2. B, l1.a); p. X = (l2.a. x * dot2 + l2. B. x * dot1)/(dot2 + dot1); p. y = (l2.a. y * dot2 + l2. B. y * dot1)/(dot2 + dot1);} bool judge (line l0, line L1, line l2) {point P; getintersect (L1, L2, P ); return dblcmp (multi (p, l0.a, l0. B)> 0; // The less than symbol is opposite to the comment in CMP () above} void addline (double X1, double Y1, double X2, double Y2) {L [Ln]. a. X = x1; L [Ln]. a. y = Y1; L [Ln]. b. X = x2; L [Ln]. b. y = Y2; L [Ln]. angle = atan2 (y2-y1, x2-x1); Order [Ln] = ln; Ln ++;} void halfplaneintersection () {int I, j; sort (Order, order + ln, CMP); for (I = 1, j = 0; I <ln; I ++) if (dblcmp (L [order [I]. angle-L [order [J]. angle)> 0) Order [+ + J] = order [I]; Ln = J + 1; DQ [0] = order [0]; DQ [1] = order [1]; bot = 0; Top = 1; for (I = 2; I <ln; I ++) {While (BOT <top & judge (L [order [I], L [DQ [Top-1], L [DQ [Top]) Top --; while (BOT <top & judge (L [order [I], L [DQ [bot + 1], L [DQ [bot]) BOT ++; DQ [++ top] = order [I];} while (BOT <top & judge (L [DQ [bot], L [DQ [Top-1], L [DQ [Top]) Top --; while (BOT <top & judge (L [DQ [Top], L [DQ [bot + 1], L [DQ [bot]) BOT ++;} bool isthereacore () {If (top-bot> 1) return true; return false;} int main () {int I, T; scanf ("% d", & T); While (t --) {scanf ("% d", & PN); for (I = 0; I <PN; I ++) scanf ("% lf", & P [I]. x, & P [I]. y); For (Ln = I = 0; I <pn-1; I ++) addline (P [I]. x, p [I]. y, P [I + 1]. x, p [I + 1]. y); addline (P [I]. x, p [I]. y, P [0]. x, p [0]. y); halfplaneintersection (); If (isthereacore () printf ("Yes \ n"); else printf ("NO \ n");} return 0 ;}


Poj 3335 rotating scoreboard

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.