# Include <stdio. h> # Include <Math. h> # Include <Algorithm> # Include <Iostream> Using Namespace STD; Const Int Maxn = 1000 ; Struct Point { Int X, Y ;}; point list [maxn]; Int Stack [maxn], top; Int Cross (point P0, Point P1, point P2) // Calculate the cross product p0p1 x p0p2 { Return (P1.x-Snapshot X) * (p2.y-Snapshot y)-(p1.y-Snapshot y) * (p2.x- Optional X );} Double DIS (point P1, point P2) // Calculate the P1P2 distance { Return SQRT (( Double ) (P2.x-p1.x) * (p2.x-p1.x) + (p2.y-p1.y) * (p2.y- P1.y ));} Bool CMP (point P1, point P2) // The polar ordering function. If the angle is the same, the distance is smaller than the previous one. { Int TMP = cross (list [ 0 ], P1, P2 ); If (TMP> 0 ) Return True ; Else If (TMP = 0 & DIS (list [ 0 ], P1) <DIS (list [ 0 ], P2 )) Return True ; Else Return False ;} Void Init ( Int N) // Enter and place the vertices at the bottom left of the page in list [0]. And performs polar sorting. { Int I, K; point P0; scanf ( " % D " , & List [ 0 ]. X, & list [ 0 ]. Y); returns x = List [ 0 ]. X; Policy = List [ 0 ]. Y; k = 0 ; For (I = 1 ; I <n; I ++ ) {Scanf ( " % D " , & List [I]. X ,& List [I]. y ); If (Optional Y> list [I]. Y) | (Optional Y = list [I]. Y) & (Optional X> List [I]. X) {returns x = List [I]. X; Policy = List [I]. Y; k = I ;}} list [k] = List [ 0 ]; List [ 0 ] = P0; sort (list + 1 , List + N, CMP );} Void Graham ( Int N ){ Int I; If (N = 1 ) {Top = 0 ; Stack [0 ] = 0 ;} If (N = 2 ) {Top = 1 ; Stack [ 0 ] = 0 ; Stack [ 1 ] = 1 ;} If (N>2 ){ For (I = 0 ; I <= 1 ; I ++) stack [I] = I; top = 1 ; For (I = 2 ; I <n; I ++ ){ While (Top> 0 & Cross (list [stack [Top- 1 ], List [stack [Top], list [I]) <= 0 ) Top -- ; Top ++ ; Stack [Top] = I ;}}}