Advertisement
MathQ_

Untitled

Jan 5th, 2021
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.13 KB | None | 0 0
  1. #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
  2. #pragma GCC optimize 03
  3. #pragma GCC optimize("unroll-loops")
  4.  
  5. #include <iostream>
  6. #include <iomanip>
  7. #include <algorithm>
  8. #include <iterator>
  9. #include <cmath>
  10. #include <ctime>
  11. #include <vector>
  12. #include <deque>
  13. #include <queue>
  14. #include <set>
  15. #include <map>
  16. #include <stack>
  17. #include <string>
  18. #include <random>
  19. #include <numeric>
  20. #include <unordered_set>
  21.  
  22. typedef long long ll;
  23. typedef long double lb;
  24.  
  25. #define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  26. #define file_in freopen("input.txt", "r", stdin);
  27. #define file_in_out freopen("cutting.in", "r", stdin); freopen("cutting.out", "w", stdout);
  28. #define mp make_pair
  29. #define all(x) (x).begin(), (x).end()
  30. #define fi first
  31. #define se second
  32.  
  33. using namespace std;
  34.  
  35. const lb pi = atan2((lb)0, (lb)-1);
  36.  
  37. struct point {
  38.     ll x, y;
  39.  
  40.     point() {
  41.         x = 0; y = 0;
  42.     }
  43.  
  44.     point(ll _x, ll _y) {
  45.         x = _x; y = _y;
  46.     }
  47. };
  48.  
  49. struct vec {
  50.     ll x, y;
  51.     lb mod;
  52.     vec(point p1, point p2) {
  53.         x = p2.x - p1.x;
  54.         y = p2.y - p1.y;
  55.         mod = sqrt(x * x + y * y);
  56.     }
  57. };
  58.  
  59. istream& operator>>(istream& in, point& p) {
  60.     cin >> p.x >> p.y;
  61.     return in;
  62. }
  63.  
  64. ostream& operator<<(ostream& out, point& p) {
  65.     cout << p.x << " " << p.y;
  66.     return out;
  67. }
  68.  
  69. ll scalar(vec v1, vec v2) {
  70.     return v1.x * v2.x + v1.y * v2.y;
  71. }
  72.  
  73. ll crossv(vec v1, vec v2) {
  74.     return v1.x * v2.y - v1.y * v2.x;
  75. }
  76.  
  77. ll sign(ll n) {
  78.     if (n == 0) {
  79.         return n;
  80.     } else {
  81.         return n / abs(n);
  82.     }
  83. }
  84.  
  85. int main() {
  86.     fast
  87.     // file_in
  88. //  file_in_out
  89.  
  90.     point A, O, B, P;
  91.     cin >> A >> O >> B >> P;
  92.     vec v1(O, P), v2(O, A), v3(O, B);
  93.  
  94.     ll cr1 = sign(crossv(v1, v2));
  95.     ll cr2 = sign(crossv(v1, v3));
  96.  
  97.     if (cr1 * cr2 <= 0) {
  98.         if (acos(scalar(v1, v2) / (v1.mod * v2.mod)) <= pi / 2 || acos(scalar(v1, v3) / (v1.mod * v3.mod)) <= pi / 2) {
  99.             cout << "YES" << "\n";
  100.         } else {
  101.             cout << "NO" << "\n";
  102.         }
  103.     } else {
  104.         cout << "NO" << "\n";
  105.     }
  106.     return 0;
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement