Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- struct Point {
- int x, y;
- };
- int main() {
- // freopen("convex.in", "r", stdin);
- // freopen("convex.out", "w", stdout);
- int n;
- cin >> n;
- vector<Point> points(n, {0, 0});
- long double x1, y1, x2, y2;
- for (int i = 0; i < n; i++) {
- cin >> points[i].x >> points[i].y;
- }
- for (int j = 0; j < n - 1; ++j) {
- x1 = points[j].x;
- y1 = points[j].y;
- x2 = points[j + 1].x;
- y2 = points[j + 1].y;
- long double A = -(y1 - y2);
- long double B = -(x2 - x1);
- long double C = -(x1 * y2 - x2 * y1);
- long double znak = A * x1 + B * y1 + C;
- for (int i = 0; i < n; ++i) {
- x2 = points[i].x;
- y2 = points[i].y;
- if (!((znak > 0 && A * x2 + B * y2 + C > 0) ||
- (znak < 0 && A * x2 + B * y2 + C < 0))) {
- cout << "NO";
- return 0;
- }
- }
- }
- cout << "YES";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement