Advertisement
biznesman

Untitled

Nov 7th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const long long mod = 1e9 + 9;
  6. const int MAXN = 1e5 + 10;
  7. const int INF = 1e9 + 7;
  8. const long long P = 31;
  9.  
  10. struct point {
  11. long long x, y;
  12.  
  13. long long norm() {
  14. return x * x + y * y;
  15. }
  16.  
  17. double len() {
  18. return sqrt(norm());
  19. }
  20. };
  21.  
  22. struct line {
  23. point a, b;
  24. };
  25.  
  26. istream &operator>>(istream &in, point &a) {
  27. in >> a.x >> a.y;
  28.  
  29. return in;
  30. }
  31.  
  32. istream &operator>>(istream &in, line &a) {
  33. in >> a.a >> a.b;
  34. return in;
  35. }
  36.  
  37. ostream &operator<<(ostream &out, const point &a) {
  38. out << a.x << ' ' << a.y << '\n';
  39.  
  40. return out;
  41. }
  42.  
  43. bool operator<(point a, point b) {
  44. if (a.x == b.x)
  45. return (a.y > b.y);
  46. return (a.x > b.x);
  47. }
  48.  
  49. point operator*(int x, point p) {
  50. return {x * p.x, x * p.y};
  51. }
  52.  
  53. int operator*(point a, point b) {
  54. return a.x * b.x + a.y * b.y;
  55. }
  56.  
  57. int operator%(point a, point b) {
  58. return a.x * b.y - a.y * b.x;
  59. }
  60.  
  61. bool operator==(point a, point b) {
  62. return ((a.x == b.x) && (a.y == b.y));
  63. }
  64.  
  65. point vect(point a, point b) {
  66. return {b.x - a.x, b.y - a.y};
  67. }
  68.  
  69. double angle(point a, point b) {
  70. double cos = (a * b) / (sqrt(a * a) * sqrt(b * b));
  71. return acos(cos) * 180 / acosl(-1.0);
  72. }
  73.  
  74. double distPoint(point a, point b) {
  75. return sqrt((b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y));
  76. }
  77.  
  78. double distLine(point s, point a, point b) {
  79. return abs((a.y - b.y) * s.x + (b.x - a.x) * s.y + (a.x * b.y - a.y * b.x)) / vect(a, b).len();
  80. }
  81.  
  82. double angle(point a, point b, point c) {
  83. point ab = vect(a, b);
  84. point ac = vect(a, c);
  85. return ab * ac;
  86. }
  87.  
  88. line a, b;
  89. int trb1, trb2, tra1, tra2, tr, tr2, tr3;
  90.  
  91. bool sign(int a, int b) {
  92. if ((a == 0 && b != 0) || (a != 0 && b == 0))
  93. return true;
  94. if ((a < 0 && b > 0) || (a > 0 && b < 0))
  95. return true;
  96. return false;
  97. }
  98.  
  99. void zeroCheck(int trb1, int trb2, int tra1, int tra2) {
  100. if (trb1 == 0 && trb2 == 0 && tra1 == 0 && tra2 == 0) {
  101. if (b.b < b.a)
  102. swap(b.b, b.a);
  103. if (a.b < a.a)
  104. swap(a.b, a.a);
  105. if (((a.a < b.a || a.a == b.a) && (b.a < a.b || b.a == a.b)) || ((b.a < a.a || b.a == a.a) && (a.a < b.b || a.a == b.b))) {
  106. cout << "YES";
  107. exit(0);
  108. } else {
  109. cout << "NO";
  110. exit(0);
  111. }
  112. }
  113. }
  114.  
  115. int main() {
  116. // ifstream cin("input.txt");
  117. // ofstream cout("output.txt");
  118. ios_base::sync_with_stdio(false);
  119. cin.tie(0);
  120.  
  121. cin >> a >> b;
  122. //cout << (vect(a.a, a.b) % vect(a.a, b.a)) << ' ' << (vect(a.a, a.b) % vect(a.a, b.b)) << ' ' << (vect(b.a, b.b) % vect(b.a, a.a)) << ' ' << (vect(b.a, b.b) % vect(b.a, a.b)) << '\n';
  123. trb1 = (vect(a.a, a.b) % vect(a.a, b.a));
  124. trb2 = (vect(a.a, a.b) % vect(a.a, b.b));
  125. tra1 = (vect(b.a, b.b) % vect(b.a, a.a));
  126. tra2 = (vect(b.a, b.b) % vect(b.a, a.b));
  127.  
  128. zeroCheck(trb1, trb2, tra1, tra2);
  129.  
  130. if (sign(trb1, trb2) && sign(tra1, tra2))
  131. cout << "YES";
  132. else
  133. cout << "NO";
  134.  
  135. return 0;
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement