Raslboyy

287

Mar 25th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. //#pragma GCC optimize("O3")
  4. //#pragma GCC optimize("unroll-loops")
  5.  
  6. #define mp make_pair
  7. #define pb push_back
  8. #define eb emplace_back
  9. #define x first
  10. #define y second
  11. #define sz(x) (int)x.size()
  12. #define all(x) begin(x), end(x)
  13. #define rall(x) rbegin(x), rend(x)
  14. #define FOR(i,a,b) for (int i = (a); i < (b); i++)
  15. #define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
  16.  
  17. using namespace std;
  18.  
  19. typedef unsigned long long ull;
  20. typedef long long ll;
  21. typedef long double ld;
  22. typedef pair<int, int> pi;
  23. typedef pair<ll, ll> pl;
  24. typedef vector<int> veci;
  25. typedef vector<bool> vecb;
  26. typedef vector<vector<int>> vvi;
  27. typedef vector<vector<bool>> vvb;
  28.  
  29. const int INF_I = 1e9;
  30. const ll INF_LL = 1e18;
  31. const int MOD = 1000000007;
  32. const double eps = 1e-6;
  33.  
  34. int main() {
  35.  
  36.     ios::sync_with_stdio(false);
  37.     cin.tie(nullptr);
  38.     cout.tie(nullptr);
  39.  
  40.     int n;
  41.     cin >> n;
  42.     vector<pl> a(n);
  43.     for (int i = 0; i < n; i++)
  44.         cin >> a[i].x >> a[i].y;
  45.     int cnt1 = 0, cnt2 = 0;
  46.     for (int i = 0; i < n; i++){
  47.         pl v1 = {a[(i+1)%n].x - a[i].x, a[(i+1)%n].y - a[i].y};
  48.         pl v2 = {a[(i+2)%n].x - a[(i+1)%n].x, a[(i+2)%n].y - a[(i+1)%n].y};
  49.         ll s = v1.x * v2.y - v1.y * v2.x;
  50.         if (s < 0)
  51.             cnt1++;
  52.         else
  53.             cnt2++;
  54.     }
  55.     if (cnt1*cnt2)
  56.         cout << "NO\n";
  57.     else
  58.         cout << "YES\n";
  59.  
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment