http://poj.org/problem?id=2398
This problem and the previous toys is the same is the output is not the same as this gives is the chaos you have to sort the bezel first
#include <iostream>#include<cstring>#include<algorithm>#include<queue>#include<cstdio>#include<cstdlib>#include<cctype>#include<math.h>#include<ctype.h>using namespacestd;#defineMemset (A, B) memset (A,b,sizeof (a))#defineN 5500typedefLong Longll;structnode{intx, Y, V;} P[n],u[n];intY2;intcmpConst void*a,Const void*b) { structNode *c, *F; C=(structNode *) A; F=(structNode *) b; returnC->x-f->x;}intFind (intNxintNyintLintR) { if(l==r-1) returnl; intMid= (L+R)/2; Node D; D.x=nx-p[mid].v; D.y=ny-Y2; if((D.X*P[MID].Y)-(d.y*p[mid].x) >0) {L=mid; R=R; returnFind (NX,NY,L,R); } Else if((D.X*P[MID].Y)-(d.y*p[mid].x) <0) {L=l; R=mid; returnFind (NX,NY,L,R); } return 0;}intMain () {intN,m,x1,x2,y1,a[n]; while(SCANF ("%d",&N) {memset (A,0); scanf ("%d %d%d%d%d",&m,&x1,&y1,&x2,&y2); p[0].x=X1; p[0].y=Y2; p[0].v=X1; for(intI=1; i<=n;i++) {scanf ("%d%d",&u[i].x,&u[i].y); } qsort (U+1Nsizeof(u[0]), CMP); for(intI=1; i<=n;i++) {p[i].x=u[i].x-u[i].y; P[i].y=y1-Y2; P[I].V=u[i].y; } p[n+1].x=x2; P[n+1].y=Y1; P[n+1].v=x2; intk,v; for(intI=0; i<m;i++) {scanf ("%d%d",&k,&W); intAa=find (K,v,0, n+1); A[AA]++; } intAns[n]; memset (ans,0); for(intI=0; i<=n;i++) { if(A[i]) {Ans[a[i]]++; }} printf ("box\n"); for(intI=1; i<=n;i++) { if(Ans[i]) printf ("%d:%d\n", I,ans[i]); } } return 0;}
Toy storage--poj2398 (Computational geometry)