Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <vector>
- #include <algorithm>
- #include <cmath>
- typedef long double ld;
- struct Point {
- int x, y;
- int norm2() const {
- return x*x+y*y;
- }
- };
- int cross(Point a, Point b) {
- return a.x * b.y - a.y * b.x;
- }
- int main() {
- // freopen("input.txt", "rt", stdin);
- int side, n;
- scanf("%d %d", &side, &n);
- std::vector<Point> p;
- for (int i = 0; i < n; ++i) {
- int x, y;
- scanf("%d %d", &x, &y);
- x = 2*x-side;
- y = 2*y-side;
- p.push_back(Point{x, y});
- if (x == 0 && y == 0) {
- printf("NO");
- return 0;
- }
- }
- if (n == 1) {
- printf("YES");
- return 0;
- }
- std::sort(p.begin(), p.end(), [](const Point& a, const Point& b){
- ld angle1 = std::atan2(ld(a.y), ld(a.x));
- ld angle2 = std::atan2(ld(b.y), ld(b.x));
- return angle1 < angle2 || (angle1 == angle2 && a.norm2() < b.norm2());
- });
- p.push_back(p[0]);
- for (int i = 1; i <= n; ++i) {
- if (cross(p[i-1], p[i]) < 0) {
- printf("YES");
- return 0;
- }
- }
- printf("NO");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement