/* Poj 2398 Toy storage is basically the same as 2318, but requires that the number of T toys be output t from small to large. Note that the sequence of the baffle is not from left to right. order, the calculation ry that needs to be sorted is that the range of a rectangle is divided into n + 1 regions by N line segments, and then there are m coordinate points, they belong to the region where they are located, that is, whether the dot is the left side of the online segment or the right side uses the cross product of the vector to ensure that the x> 0 points of the vector where the line segment is located are the left side of the cross product. <0 points to the right side of the binary solution */# include <stdio. h> # include <string. h> # include <stdlib. h> struct point {int X, Y ;}; struct zone {point S, X; int n ;}l [5050]; int n, m, Mm [1010], x1, x2, Y1, Y2; int cross (point P, point S, point E) {return (E. x-s.x) * (p. y-s.y)-(P. x-s.x) * (E. y-s.y);} int CMP (const void * a, const void * B) {zone * C, * D; C = (zone *) A, D = (zone *) b; return C-> S. x-D-> S. x;} int main () {int I, A, B, Max, Min, mid, CAS = 0; point Z; while (scanf ("% d ", & N), n) {memset (mm, 0, sizeof (MM); scanf ("% d", & M, & X1, & Y1, & X2, & Y2); L [0]. s. X = x1, L [0]. s. y = Y1, L [0]. x. X = x1, L [0]. x. y = Y2, L [0]. n = 0; L [n + 1]. s. X = x2, L [n + 1]. s. y = Y1, L [n + 1]. x. X = x2, L [n + 1]. x. y = Y2, L [n + 1]. n = 0; for (I = 1; I <= N; I ++) {scanf ("% d", & A, & B ); L [I]. s. X = A, L [I]. s. y = Y1, L [I]. x. X = B, L [I]. x. y = Y2, L [I]. n = 0;} qsort (L, N + 2, sizeof (L [0]), CMP); for (I = 1; I <= m; ++ I) {scanf ("% d", & A, & B); Z. X = A, Z. y = B; min = 0, max = n + 1; while (min + 1 <max) {mid = (min + max)/2; If (Cross (Z, L [Mid]. x, L [Mid]. s)> 0) max = mid; else min = mid;} l [Min]. N ++ ;}for (I = 0; I <= N; ++ I) mm [L [I]. n] ++; printf ("Box \ n"); for (I = 1; I <= m; I ++) if (Mm [I]) printf ("% d: % d \ n", I, Mm [I]);} return 0 ;}