Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef unsigned int ui;
  6. typedef long long ll;
  7. typedef long double ld;
  8.  
  9. const int MAXN = 777;
  10. ll M = 1000003;
  11.  
  12. struct pnt {
  13. ll x;
  14. ll y;
  15. };
  16.  
  17.  
  18. pnt a[MAXN];
  19.  
  20. ll v(pnt a, pnt b) {
  21. return a.x * b.y - b.x * a.y;
  22. }
  23. ll S(pnt a, pnt b, pnt c) {
  24. ll s = v({c.x - b.x, c.y - b.y}, {a.x - b.x, a.y - b.y});
  25. return (s);
  26. }
  27.  
  28. int main() {
  29. ios_base::sync_with_stdio(0);
  30. cin.tie(0);
  31. int t;
  32. cin >> t;
  33. int z = 0;
  34. while (t > 0) {
  35. int n;
  36. cin >> n;
  37. for (int i = 0; i < n; ++i) {
  38. cin >> a[i].x >> a[i].y;
  39. }
  40. ll s = 0;
  41.  
  42. for (int i = 0; i < n; ++i) {
  43. for (int j = i + 1; j < n; ++j) {
  44. ll s1 = 0;
  45. ll s2 = 0;
  46. ll c1 = 0, c2 = 0;
  47. for (int k = 0; k < n; ++k) {
  48. if (k == i || k == j) continue;
  49. ll x = S(a[j], a[k], a[i]) / 2;
  50. if (x > 0) {
  51. s1 += x;
  52. c1++;
  53. }
  54. if (x < 0) {
  55. s2 += x;
  56. c2++;
  57. }
  58. }
  59. if (c1 && c2) {
  60. s = s + s1 * c2 - s2 * c1;
  61. s %= M;
  62. }
  63. }
  64. }
  65. cout << "Case " << ++z << ": " << s % M << '\n';
  66. t--;
  67. }
  68.  
  69. return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement