Hex Artifact Content
Not logged in

Artifact a5ea821173c9c75552f74d647e264fbbcfcb29cd:


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 41 72 65 61 20 6f 66 20 61 20 70 6f 6c  // Area of a pol
0050: 79 67 6f 6e 0a 2f 2f 20 20 20 4f 28 4e 29 0a 2f  ygon.//   O(N)./
0060: 2f 0a 2f 2f 20 56 65 72 69 66 69 65 64 20 62 79  /.// Verified by
0070: 0a 2f 2f 20 20 20 2d 20 53 52 4d 20 33 33 37 20  .//   - SRM 337 
0080: 44 69 76 31 20 4c 56 33 0a 2f 2f 20 20 20 2d 20  Div1 LV3.//   - 
0090: 53 52 4d 20 34 38 36 20 44 69 76 31 20 4c 56 33  SRM 486 Div1 LV3
00a0: 0a 2f 2f 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  .//-------------
00b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
00c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
00d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
00e0: 0a 0a 64 6f 75 62 6c 65 20 6f 75 74 65 72 5f 70  ..double outer_p
00f0: 72 6f 64 28 63 6f 6e 73 74 20 43 4d 50 26 20 61  rod(const CMP& a
0100: 2c 20 63 6f 6e 73 74 20 43 4d 50 26 20 62 29 20  , const CMP& b) 
0110: 7b 20 72 65 74 75 72 6e 20 69 6d 61 67 28 63 6f  { return imag(co
0120: 6e 6a 28 61 29 2a 62 29 3b 20 7d 0a 0a 64 6f 75  nj(a)*b); }..dou
0130: 62 6c 65 20 61 72 65 61 28 20 63 6f 6e 73 74 20  ble area( const 
0140: 76 65 63 74 6f 72 3c 70 74 3e 26 20 71 20 29 0a  vector<pt>& q ).
0150: 7b 0a 09 64 6f 75 62 6c 65 20 61 20 3d 20 30 2e  {..double a = 0.
0160: 30 3b 0a 0a 09 70 74 20 6f 20 3d 20 71 5b 30 5d  0;...pt o = q[0]
0170: 3b 0a 09 66 6f 72 28 69 6e 74 20 69 3d 31 3b 20  ;..for(int i=1; 
0180: 69 2b 31 3c 71 2e 73 69 7a 65 28 29 3b 20 2b 2b  i+1<q.size(); ++
0190: 69 29 0a 09 09 61 20 2b 3d 20 6f 75 74 65 72 5f  i)...a += outer_
01a0: 70 72 6f 64 28 71 5b 69 5d 2d 6f 2c 20 71 5b 69  prod(q[i]-o, q[i
01b0: 2b 31 5d 2d 6f 29 3b 0a 09 72 65 74 75 72 6e 20  +1]-o);..return 
01c0: 61 62 73 28 61 29 20 2f 20 32 3b 0a 7d 0a        abs(a) / 2;.}.