Advertisement
MiinaMagdy

10865 - Brownie Points

Oct 17th, 2023
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.06 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4.  
  5. using namespace std;
  6. using namespace __gnu_pbds;
  7. #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
  8. #define multi_ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
  9. #define endl "\n"
  10. #define MOD 1000000007
  11. #define INF 2000000000
  12. #define all(s) s.begin(), s.end()
  13. #define rall(s) s.rbegin(), s.rend()
  14. #define sz(x) int(x.size())
  15. #define crossProd(A,B) ((conj(A)*(B)).imag())
  16. #define dotProd(A,B) ((conj(A)*(B)).real())
  17.  
  18. typedef long long ll;
  19. typedef long double ld;
  20. typedef unsigned long long ull;
  21.  
  22. #define EPS 1e-9
  23. #define PI acos(-1)
  24. #define X real()
  25. #define Y imag()
  26. #define normalize(a) (a) / length(a)
  27. #define lengthSqr(p) dot_prod(p, p)
  28. #define rotateO(p, ang) p * exp(point(0, ang))
  29. #define rotateA(p, about, ang) rotateO(vector((about), (p)), ang) + (about)
  30. #define reflicatO(v, m) conj(v / m) * m
  31. #define reflicatA(v, about, m) conj(vector(about, v) / vector(about, m)) * vector(about, m) + about
  32.  
  33. template<typename T>
  34. class point {
  35. public:
  36. T x, y;
  37. point() {
  38. x = y = 0;
  39. }
  40. point(T _x, T _y) {
  41. x = _x;
  42. y = _y;
  43. }
  44. point(const point<T> &p) {
  45. x = p.x;
  46. y = p.y;
  47. }
  48. // vector from point a to point b
  49. point(const point<T> &a, const point<T> &b) {
  50. *this = b - a;
  51. }
  52. point operator=(const point<T> &p) {
  53. x = p.x;
  54. y = p.y;
  55. return *this;
  56. }
  57. point operator+(const point<T> &p) const {
  58. return point(x + p.x, y + p.y);
  59. }
  60. point operator-(const point<T> &p) const {
  61. return point(x - p.x, y - p.y);
  62. }
  63. // dot product
  64. T operator*(const point<T> &p) const {
  65. return x * p.x + y * p.y;
  66. }
  67. // cross product
  68. T operator^(const point<T> &p) const {
  69. return x * p.y - y * p.x;
  70. }
  71. point operator*(const T &factor) const {
  72. return point(x * factor, y * factor);
  73. }
  74. point operator/(const T &factor) const {
  75. return point(x / factor, y / factor);
  76. }
  77. friend istream &operator>>(istream &is, point<T> &p) {
  78. is >> p.x >> p.y;
  79. return is;
  80. }
  81. friend ostream &operator<<(ostream &os, const point<T> &p) {
  82. os << p.x << " " << p.y;
  83. return os;
  84. }
  85. bool operator==(const point<T> &p) const {
  86. return (x == p.x && y == p.y);
  87. }
  88. bool operator!=(const point<T> &p) const {
  89. return (x != p.x || y != p.y);
  90. }
  91. ld arg() const {
  92. return atan2l(y, x);
  93. }
  94. T lenSqr() const {
  95. return x * x + y * y;
  96. }
  97. double len() const {
  98. return hypot(x, y);
  99. }
  100. // distance
  101. double dist(const point<T> &p) const {
  102. return hypot(x - p.x, y - p.y);
  103. }
  104. // distance squared
  105. T distSqr(const point<T> &p) const {
  106. return (x - p.x) * (x - p.x) + (y - p.y) * (y - p.y);
  107. }
  108. // returns 1 for counterclockwise order
  109. // returns -1 for clockwise order
  110. // returns 0 if the points are collinear
  111. int orientation(const point<T> &p, const point<T> &q) const {
  112. T val = (q - p) ^ (*this - q);
  113. if (val == 0) {
  114. return 0;
  115. }
  116. return (val > 0) ? 1 : -1;
  117. }
  118. // check intersection between line segment p1q1 and line segment p2q2
  119. static bool intersect_ab_cd(point<T> a, point<T> b, point<T> c, point<T> d, point<T> &intersect) {
  120. point<T> u(a, b);
  121. point<T> v(c, d);
  122. point<T> w(c, a);
  123. T d1 = u ^ v;
  124. T d2 = v ^ w;
  125. T d3 = u ^ w;
  126. if (d1 == 0)
  127. return false;
  128. double t1 = d2 / d1;
  129. double t2 = d3 / d1;
  130. intersect = a + u * t1;
  131. return t1 >= EPS && t2 >= EPS && t2 <= 1 + EPS; // e.g ab is a ray, cd is a segment
  132. }
  133. };
  134.  
  135. // ab segment, c point
  136. double segPointDist(point<double> a, point<double> b, point<double> c, point<double> &ans) {
  137. point<double> u(a, b), v(b, c), w(a, c);
  138. double d1, d2;
  139. if ((d1 = w * u) < -EPS) {
  140. ans = a;
  141. return a.dist(c);
  142. }
  143. if ((d2 = u * u) <= d1) {
  144. ans = b;
  145. return b.dist(c);
  146. }
  147. double t = d1 / d2;
  148. ans = a + u * t;
  149. return ans.dist(c);
  150. }
  151.  
  152. void solve() {
  153. int n;
  154. while (cin >> n, n) {
  155. vector<point<ll>> ps(n);
  156. for (auto& p : ps) {
  157. cin >> p;
  158. }
  159. for (int i = 0; i < n; i++) {
  160. if (i == n / 2) continue;
  161. ps[i] = ps[i] - ps[n / 2];
  162. }
  163. ps[n / 2] = point<ll>(0, 0);
  164. int cnt1 = 0, cnt2 = 0;
  165. for (auto& p : ps) {
  166. if (p.x * p.y < 0)
  167. cnt1++;
  168. if (p.x * p.y > 0)
  169. cnt2++;
  170. }
  171. cout << cnt2 << " " << cnt1 << endl;
  172. }
  173. }
  174.  
  175. int main(void)
  176. {
  177. ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  178. int testcase = 1;
  179. // cin >> testcase;
  180. while (testcase--)
  181. solve();
  182. return 0;
  183. }
Tags: UVA Geomet
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement