Find a present (find) Title Description
New Year is coming, your friends and you (a total of K-person) are full of gifts, you let your friends take first, but everyone can only take the present to their nearest gift [of course, if there are multiple gifts in parallel to your distance (accurate to four digits after the decimal point, all operations are the tail), these gifts belong to this person]. Now your position is the origin (0,0), and the position of each gift is expressed in coordinates. Now tell you the coordinates of each gift, and who sent each gift. To find out how far your gift is from you, how many gifts you can get, and who sent the gifts. If you can't get a gift, please output "555 ...".
Input
Line 1th: N and K indicate the number and number of gifts (k≤n≤100000) respectively;
2nd to n+1: Each line first presents the person's name, then the gift coordinates (x, y) (the coordinate absolute value is less than 106). The data is separated by a space.
Output
Line 1th: D and U indicate how far the gift is from you (as long as you go to the end of the whole number) and how many gifts you can get.
2nd to u+1: One person per line, indicating the giver (output in the order entered).
Sample input
5 2Jason 1 1Herry 4 4Patty 3 4Tom 2 10Petter 5 10
Sample output
5 1Patty
Analysis: To find the distance to pay attention to a long long can, set used to go to heavy, and finally output the answer by order;
Code:
#include <iostream>#include<cstdio>#include<cstdlib>#include<cmath>#include<algorithm>#include<climits>#include<cstring>#include<string>#include<Set>#include<map>#include<queue>#include<stack>#include<vector>#include<list>#include<ext/rope>#defineRep (I,m,n) for (i=m;i<=n;i++)#defineRSP (It,s) for (Set<int>::iterator It=s.begin (); It!=s.end (); it++)#defineVI vector<int>#definePII pair<int,int>#defineMoD 1000000007#defineINF 0x3f3f3f3f#definePB Push_back#defineMP Make_pair#defineFi first#defineSe Second#definell Long Long#definePi ACOs (-1.0)Const intmaxn=1e5+Ten;Const intdis[4][2]={{0,1},{-1,0},{0,-1},{1,0}};using namespacestd;using namespace__gnu_cxx;ll gcd (ll p,ll q) {returnq==0? P:GCD (q,p%q);} ll Qpow (ll p,ll q) {ll F=1; while(q) {if(q&1) f=f*p;p=p*p;q>>=1;}returnF;}intN,m;pair<ll,string>A[MAXN],B[MAXN];Set<ll>Q;vector<string>pp;intMain () {inti,j,k,t; CIN>>n>>m; Rep (I,0, N-1) { stringp; ll X,y,r; CIN>>p>>x>>y; R= (ll) (sqrt (1.0*X*X+Y*Y) *10000); A[i]=MP (R,P); B[i]=A[i]; Q.insert (R); } sort (A,a+N); if(Q.size () <m) puts ("555 ..."); Else { intnow=0; ll ans; for(ll X:q) {now++;if(now==m) {ans=x; Break;}} Rep (I,0, N-1) { if(ans==b[i].fi) PP.PB (b[i].se); } cout<<ans/10000<<" "<<pp.size () <<Endl; for(stringX:PP) cout<<x<<Endl; } //System ("pause"); return 0;}
Find a present (find)