The main topic: give some hash point and then the initial point is the coordinates of the bottom of the leftmost point, and then only go to the left, to find out the maximum number of points can pass, the serial number output. Analysis: First find out the initial point, and then constantly sort out the nearest bump .... Complexity is N^2*log (n) .... Not a little more, so feel free to play. The code is as follows:=========================================================================================================== ==========
#include <stdio.h>#include<math.h>#include<algorithm>using namespacestd;Const intMAXN =107;Const DoubleEPS = 1e-8;structpoint{Doublex, y; intID; Point (Doublex=0,Doubley=0): X (x), Y (y) {} pointoperator- (ConstPoint &tmp)Const{ returnPoint (x-tmp.x, ytmp.y); } Double operator*(ConstPoint &tmp)Const{ returnx*tmp.x + y*tmp.y; } Double operator^(ConstPoint &tmp)Const{ returnx*tmp.y-y*tmp.x; }};DoubleDist (Point A, point B) {returnsqrt (A-B) * (Ab));} Point P[MAXN];intKi;BOOLCMP (Point A, point B) {DoubleT = (A-p[ki]) ^ (b-P[ki]); if(Fabs (T) <EPS)returnDist (P[ki], a) <Dist (P[ki], b); returnT >EPS;}intMain () {intT; scanf ("%d", &T); while(t--) { intI, N; scanf ("%d", &N); for(intI=0; i<n; i++) {scanf ("%D%LF%LF", &p[i].id, &p[i].x, &p[i].y); if(P[i].y < p[0].y | | (p[i].y==p[0].y && p[i].x < p[0].x)) swap (P[i], p[0]); } ki=0; for(i=1; i<n; i++, ki++) {sort (P+i, p+N, CMP); } printf ("%d", N); for(i=0; i<n; i++) printf ("%d", p[i].id); printf ("\ n"); } return 0;}
Space Ant-poj 1696 (convex bag)