Question: the points on the convex hull are output in a counterclockwise order, and the lower left corner is the starting point. Analysis: Computation of geometric and convex hull. The question will be given enough points on the convex bag, which can be ignored if they are not on the convex bag. Note: The handling of common points will overflow if int cross multiplication is used. [Cpp] # include <algorithm> # include <iostream> # include <cstdlib> # include <cstdio> # include <cmath> using namespace std; typedef struct pnode {double x, y, d;} point; point P [100001]; point S [100001]; point MP; double crossproduct (point a, point B, point c) // AB to ac {return (B. x-a.x) * (c. y-a.y)-(c. x-a.x) * (B. y-a.y);} double dist (point a, point B) {return sqrt (B. x-a.x) * (B. x-a.x) +. y-a.y )*( B. y-a.y);} bool cmp1 (point a, point B) {if (. x = B. x) return. y <B. y; else return. x <B. x;} bool cmp2 (point a, point B) {return crossproduct (P [0], a, B)> 0;} bool cmp3 (point a, point B) {double cp = crossproduct (P [0], a, B); if (cp = 0.0) {if (! Crossproduct (P [0], a, MP) // return. d> B. d; else return. d <B. d;} else return cp> 0;} void Graham (int N) {sort (P + 0, P + N, cmp1); sort (P + 1, P + N, cmp2); // process the same line for (int I = 1; I <N; ++ I) P [I]. d = dist (P [0], P [I]); MP = P [N-1]; sort (P + 1, P + N, cmp3 ); int top =-1; if (N> 0) S [++ top] = P [0]; if (N> 1) S [++ top] = P [1]; if (N> 2) {S [++ top] = P [2]; for (int I = 3; I <N; ++ I) {while (crossproduct (S [top-1], S [top], P [I]) <0) -- top; S [++ top] = P [I] ;}} printf ("% d \ n", top + 1); for (int I = 0; I <= top; ++ I) printf ("%. 0lf %. 0lf \ n ", S [I]. x, S [I]. y) ;}int main () {int N, T; char C; while (scanf ("% d", & T )! = EOF) while (T --) {scanf ("% d", & N); int count = 0; for (int I = 0; I <N; ++ I) {scanf ("% lf % c", & P [count]. x, & P [count]. y, & C); if (C = 'y') count ++;} Graham (count);} return 0 ;}