1 //Cross product judgment POJ16962 3#include <iostream>4#include <algorithm>5#include <cstring>6#include <cstdio>7#include <vector>8#include <cmath>9#include <map>Ten using namespacestd; One #defineLL Long Long Atypedef pair<int,int>PII; - Const DoubleINF =123456789012345.0; - Const intMOD =998244353; the Const intN = 2e5+Ten; - Const intMaxx =200010; - #defineCLC (A, B) memset (A,b,sizeof (a)) - Const DoubleEPS = 1e-8; + voidFre () {freopen ("In.txt","R", stdin);} - voidFreout () {freopen ("OUT.txt","W", stdout);} +InlineintRead () {intx=0, f=1;CharCh=getchar (); while(ch>'9'|| ch<'0') {if(ch=='-') f=-1; Ch=getchar ();} while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; Ch=getchar ();}returnx*F;} A at intSgnDoublex) { - if(Fabs (x) < EPS)return 0; - if(X <0)return-1; - Else return 1; - } - in structpoint{ - Doublex, y; to intindex; + Point () {} -Point (Double_x,Double_y) { thex = _x;y =_y; * } $Pointoperator-(ConstPoint &b)Const{Panax Notoginseng returnPoint (X-b.x,y-b.y); - } the Double operator^(ConstPoint &b)Const{ + returnx*b.y-y*b.x; A } the Double operator*(ConstPoint &b)Const{ + returnx*b.x + y*b.y; - } $ }; $ - DoubleDist (Point A,point b) { - returnsqrt (A-B) * (Ab)); the } - Wuyi intPos; thePoint p[ the]; - BOOLCMP (point A,point b) { Wu DoubleTmp= (A-p[pos]) ^ (b-P[pos]); - if(SGN (tmp) = =0){ About returnDist (A,p[pos]) <Dist (B,p[pos]); $ } - Else if(SGN (TMP) <0)return false; - Else return true; - } A + intMain () { the intT,n; -scanf"%d",&T); $ while(t--){ thescanf"%d",&n); the for(intI=0; i<n;i++){ thescanf"%D%LF%LF",&p[i].index,&p[i].x,&p[i].y); the if(p[i].y<p[0].y| | (p[i].y==p[0].y&&p[i].x<p[0].x)) { -Swap (p[i],p[0]); in } the } thepos=0; About for(intI=0; i<n;i++){ theSort (p+i,p+n,cmp); thepos++; the } +printf"%d", n); - for(intI=0; i<n;i++) theprintf"%d", P[i].index);Bayiprintf"\ n"); the } the return 0; -}
Cross product judgment POJ1696