#C4956. Drone Pathfinding

    ID: 48551 Type: Default 1000ms 256MiB

Drone Pathfinding

Drone Pathfinding

You are given an \( n \times n \) grid. The drone starts at cell \((1,1)\) and its destination is cell \((n,n)\). The drone can only move either right or down at each step.

There are obstacles placed in some cells which the drone cannot enter. Each obstacle is specified by its coordinates \((x, y)\). The starting cell \((1,1)\) and the destination cell \((n,n)\) are guaranteed to be free of obstacles.

Your task is to determine whether the drone can reach the destination (\((n,n)\)) from the starting position (\((1,1)\)) without colliding with any obstacles.

inputFormat

The input is read from standard input (stdin) and has the following format:

  • The first line contains a single integer \( n \) representing the size of the grid.
  • The second line contains a single integer \( k \) representing the number of obstacles.
  • Each of the next \( k \) lines contains two space-separated integers \( x \) and \( y \) representing the coordinates of an obstacle.

outputFormat

Output a single line to standard output (stdout) with the string "YES" if the drone can reach cell \((n,n)\) from \((1,1)\) without encountering an obstacle, and "NO" otherwise.

## sample
4
3
2 2
3 3
4 2
YES