The Giant and the Ghost

Source: Internet
Author: User

I don't know if I wrote it or not.

2333333

Main: Find the bottom leftmost point, with the rest of the point formation angle, the angle of the order, if the remaining point and the beginning of the point corresponding (the Giant and the ghost corresponding) to complete the pairing, no, according to the angle from small to large search, giants and ghosts as the number of complete pairing, the next round ... 22222

#include <iostream>#include<cstdio>#include<cmath>#include<cstring>#include<algorithm>#include<cstdlib>#include<stack>#include<cctype>#include<string>#include<malloc.h>#include<queue>#include<map>using namespacestd;Const intINF =0xFFFFFF;Const DoubleESP = 10e-8;Const DoublePi =4* ATAN (1.0);Const intMAXN = -+Ten;Const Long LongMoD =2147483647;Const intDr[] = {1,0,-1,0,-1,1,-1,1};Const intDc[] = {0,1,0,-1,1,-1,-1,1};typedefLong LongLL; ll GAC (ll A,ll b) {returnB?GAC (b,a%b): A;}structguest{DoubleX,y,angle; intv; intNUM1; intnum2; BOOL operator< (ConstGuest a)Const{        if(ABS (Y-A.Y) <ESP)returnX <a.x; returnY <a.y; }};BOOLcmpConstGuest A,ConstGuest B) {    Doublex =A.angle; Doubley =B.angle; //cout << x << ' << y << ';    if((X >0&& y >0) || (X <0&& y <0)|| (ABS (x) < esp && y >0)|| (ABS (y) <esp && x >0)){       //cout << (x < y) << Endl;        return(X <y); }  //cout <<! (x < y) << '! ' << Endl;    return! (X <y);}DoubleGet_angle (guest a,guest b) {if(ABS (A.Y-B.Y) <ESP) {        if(B.x-a.x >0)//It can't be completely coincident .            return 0; Else            return-1*esp* -; }    if(ABS (a.x-b.x) <ESP)return 0xFFFFFFF; return(A.Y-B.Y)/(a.x-b.x);} Guest arr[ +];voidDisintSinte) {    if(E-s = =1) {arr[s].num2=Arr[e].num1; Arr[e].num2=Arr[s].num1; return; } sort (arr+s,arr+e+1); intsum =arr[s].v;  for(inti = s+1; I <= e;i++) {Arr[i].angle=Get_angle (Arr[s],arr[i]); } sort (arr+s+1, arr+e+1, CMP); intt =s;  while(sum) {sum+ = arr[++t].v;    } dis (s,t); Dis (t+1, E);}intMain () {#ifndef Online_judge freopen ("Inpt.txt","R", stdin);#endif    intN;  while(~SCANF ("%d",&N)) {         for(inti =0; I < n;i++) {scanf ("%D%LF%LF",&arr[i].num1,&arr[i].x,&arr[i].y); ARR[I].V=1; Arr[i].num2=0; }         for(inti = N;i <2*n;i++) {scanf ("%D%LF%LF",&arr[i].num1,&arr[i].x,&arr[i].y); ARR[I].V= -1; Arr[i].num2=0; } Dis (0,2*n-1);  for(inti =0; I <2*n;i++){            if(Arr[i].v >0) {cout<< Arr[i].num1 <<' '<< arr[i].num2 <<Endl; }        }    }    return 0;}

The Giant and the Ghost

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.