Title Link: http://poj.org/problem?id=2398
Thinking RT, like POJ2318, is the need to sort, the output is not the same. Draw it by hand and you'll see. Pay attention to fork when AXB is to judge A in B clockwise or counterclockwise side, >0 is clockwise measurement, <0 is counterclockwise side, the subject corresponds to the right, left, special attention.
1 /*2 ━━━━━┒ギリギリ♂eye! 3 ┓┏┓┏┓┃キリキリ♂mind! 4 ┛┗┛┗┛┃\0/5 ┓┏┓┏┓┃/6 ┛┗┛┗┛┃ノ)7 ┓┏┓┏┓┃8 ┛┗┛┗┛┃9 ┓┏┓┏┓┃Ten ┛┗┛┗┛┃ One ┓┏┓┏┓┃ A ┛┗┛┗┛┃ - ┓┏┓┏┓┃ - ┃┃┃┃┃┃ the ┻┻┻┻┻┻ - */ -#include <algorithm> -#include <iostream> +#include <iomanip> -#include <cstring> +#include <climits> A#include <complex> at#include <fstream> -#include <cassert> -#include <cstdio> -#include <bitset> -#include <vector> -#include <deque> in#include <queue> -#include <stack> to#include <ctime> +#include <Set> -#include <map> the#include <cmath> * using namespacestd; $ #defineFr FirstPanax Notoginseng #defineSC Second - #defineCL Clear the #defineBUG puts ("Here!!!") + #defineW (a) while (a--) A #definePB (a) push_back (a) the #defineRint (a) scanf ("%d", &a) + #defineRll (a) scanf ("%lld", &a) - #defineRs (a) scanf ("%s", a) $ #defineCIN (a) CIN >> a $ #defineFRead () freopen ("in", "R", stdin) - #defineFWrite () freopen ("Out", "w", stdout) - #defineRep (i, Len) for (int i = 0; i < (len); i++) the #defineFor (I, A, Len) for (int i = (a); I < (len); i++) - #defineCls (a) memset ((a), 0, sizeof (a))Wuyi #defineCLR (A, X) memset ((a), (x), sizeof (a)) the #defineFull (a) memset ((a), 0x7f7f, sizeof (a)) - #defineLRT RT << 1 Wu #defineRRT RT << 1 | 1 - #definePi 3.14159265359 About #defineRT return $ #defineLowbit (x) x & (-X) - #defineOnenum (x) __builtin_popcount (x) -typedefLong LongLL; -typedefLong DoubleLD; Atypedef unsignedLong LongULL; +typedef pair<int,int>PII; thetypedef pair<string,int>psi; -typedef map<string,int>MSI; $typedef vector<int>VI; thetypedef vector<ll>VL; thetypedef vector<vl>VVL; thetypedef vector<BOOL>vb; the -typedefstructPoint { in intx, y; the Point () {} thePoint (intXxintyy): X (xx), Y (yy) {} About BOOL operator==(point P) { the returnx = = p.x && y = =p.y; the } the BOOL operator<(point P) { + if(x = = p.x)returnY <p.y; - returnX <p.x; the }Bayi }point; thetypedefstructLine { the Point A, b; - Line () {} - Line (point AA, point BB): A (AA), B (BB) {} the }line; the Const intMAXN =5050; the Const intMAXM =5050; the Line LINE[MAXN]; - Point S, E; the intN, M; the intTMP[MAXM]; the intANS[MAXM];94 the intOK (point P, line L) { theRT ((L.B.Y-L.A.Y) * (p.x-l.a.x)-(P.Y-L.A.Y) * (l.b.x-l.a.x)); the }98 About BOOLCMP (line A, line B) { - if(A.A = = B.A)returnA.B <b.b;101 returnA.A <B.A;102 }103 104 intMain () { the //FRead ();106 intx1, x2;107 BOOLFlag =1;108 while(~rint (n) &&N) {109 Cls (TMP); Cls (ans); the Rint (m); Rint (s.x); Rint (S.Y); Rint (e.x); Rint (E.Y);111 Rep (i, n) { the Rint (x1); Rint (x2);113Line[i] =Line (Point ( x1, S.y), point (x2, e.y)); the } theLine[n] =Line (Point (e.x, S.y), e); the Point p;117Sort (line, line+n+1, CMP);118 W (m) {119 Rint (p.x); Rint (P.Y); - intL =0, r =N;121 intret;122 while(L <=r) {123 intm = (L + r) >>1;124 if(OK (P, line[m]) >0) { theRET =m;126r = M-1;127 } - ElseL = m +1;129 } thetmp[ret]++;131 } the intHi =0;133Rep (i, n+1) {134Hi =max (Hi, Tmp[i]);135ans[tmp[i]]++;136 }137printf"box\n");138for (I,1, hi+1) {139 if(Ans[i]) printf ("%d:%d\n", I, ans[i]); $ }141 }142Rt0;143}
[POJ2398] Toy Storage (calculates geometry, two points, and determines which side of the line segment)