Artifact 81dbefbd30f15e7930198a1946498518b4e58abc:
0000: 2f 2f 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d //--------------
0010: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0020: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0030: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a ---------------.
0040: 2f 2f 20 63 63 77 0a 2f 2f 0a 2f 2f 20 56 65 72 // ccw.//.// Ver
0050: 69 66 69 65 64 20 62 79 0a 2f 2f 20 20 20 2d 20 ified by.// -
0060: 53 52 4d 20 34 39 32 20 44 69 76 31 20 4c 56 31 SRM 492 Div1 LV1
0070: 0a 2f 2f 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d .//-------------
0080: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
0090: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
00a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
00b0: 0a 0a 64 6f 75 62 6c 65 20 6f 75 74 65 72 5f 70 ..double outer_p
00c0: 72 6f 64 28 63 6f 6e 73 74 20 43 4d 50 26 20 61 rod(const CMP& a
00d0: 2c 20 63 6f 6e 73 74 20 43 4d 50 26 20 62 29 20 , const CMP& b)
00e0: 7b 20 72 65 74 75 72 6e 20 69 6d 61 67 28 63 6f { return imag(co
00f0: 6e 6a 28 61 29 2a 62 29 3b 20 7d 0a 64 6f 75 62 nj(a)*b); }.doub
0100: 6c 65 20 69 6e 6e 65 72 5f 70 72 6f 64 28 63 6f le inner_prod(co
0110: 6e 73 74 20 43 4d 50 26 20 61 2c 20 63 6f 6e 73 nst CMP& a, cons
0120: 74 20 43 4d 50 26 20 62 29 20 7b 20 72 65 74 75 t CMP& b) { retu
0130: 72 6e 20 72 65 61 6c 28 63 6f 6e 6a 28 61 29 2a rn real(conj(a)*
0140: 62 29 3b 20 7d 0a 0a 69 6e 74 20 63 63 77 28 63 b); }..int ccw(c
0150: 6f 6e 73 74 20 43 4d 50 26 20 61 2c 20 43 4d 50 onst CMP& a, CMP
0160: 20 62 2c 20 43 4d 50 20 63 29 20 7b 0a 09 62 20 b, CMP c) {..b
0170: 2d 3d 20 61 3b 20 63 20 2d 3d 20 61 3b 0a 09 69 -= a; c -= a;..i
0180: 66 28 20 6f 75 74 65 72 5f 70 72 6f 64 28 62 2c f( outer_prod(b,
0190: 63 29 20 3e 20 30 20 29 20 72 65 74 75 72 6e 20 c) > 0 ) return
01a0: 2b 31 3b 20 2f 2f 20 63 6f 75 6e 74 65 72 20 63 +1; // counter c
01b0: 6c 6f 63 6b 77 69 73 65 0a 09 69 66 28 20 6f 75 lockwise..if( ou
01c0: 74 65 72 5f 70 72 6f 64 28 62 2c 63 29 20 3c 20 ter_prod(b,c) <
01d0: 30 20 29 20 72 65 74 75 72 6e 20 2d 31 3b 20 2f 0 ) return -1; /
01e0: 2f 20 63 6c 6f 63 6b 77 69 73 65 0a 09 69 66 28 / clockwise..if(
01f0: 20 69 6e 6e 65 72 5f 70 72 6f 64 28 62 2c 63 29 inner_prod(b,c)
0200: 20 3c 20 30 20 29 20 72 65 74 75 72 6e 20 2b 32 < 0 ) return +2
0210: 3b 20 2f 2f 20 63 2d 2d 5b 61 2d 2d 62 5d 20 6f ; // c--[a--b] o
0220: 6e 20 6c 69 6e 65 0a 09 69 66 28 20 6e 6f 72 6d n line..if( norm
0230: 28 62 29 20 3c 20 6e 6f 72 6d 28 63 29 20 29 20 (b) < norm(c) )
0240: 20 20 72 65 74 75 72 6e 20 2d 32 3b 20 2f 2f 20 return -2; //
0250: 5b 61 2d 2d 62 5d 2d 2d 63 20 6f 6e 20 6c 69 6e [a--b]--c on lin
0260: 65 0a 09 72 65 74 75 72 6e 20 30 3b 20 2f 2f 20 e..return 0; //
0270: 5b 61 2d 2d 63 2d 2d 62 5d 20 6f 6e 20 6c 69 6e [a--c--b] on lin
0280: 65 0a 7d 0a e.}.