LCC '21 Contest 4 J4 - Stacy the Space Rover

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Stacy the space rover is roaming around in space. The planet she is on can be denoted by a cartesian coordinate system. She is being remote controlled by her operator, sitting in the space shuttle located at (0,0). The operator remotely sends a series of N commands to Stacy. Each command consists of 2 values, X and Y, indicating the X and Y distance she must move, respectively.

At the end of the set of commands, Stacy must make her way back to the space shuttle at (0,0). To be the most efficient, Stacy's operator has coded her to move in a straight line directly from her location to the space shuttle.

Unbeknown to the space shuttle operator, M rocks landed on the planet right as Stacy begins to make her way back. Since Stacy's operator did not prepare for these rocks, they did not prepare her to maneuver around them. If Stacy runs into a rock, she will break!

Given the N commands Stacy must make, and the M rocks landed on the planet, can you output if Stacy will make it back or not?

Input Specification

The first line of input will contain two space-separated integers, N (1 \leq N \leq 10^3) and M (0 \leq M \leq 10^2), the number of commands Stacy must make, and the number of rocks that landed on the planet just as Stacy plans to head back, respectively.

The next N lines will contain two space-separated integers, x_i (-10^2 \leq x_i \leq 10^2) and y_i (-10^2 \leq y_i \leq 10^2), the X distance she must move, and the Y distance she must move, respectively.

The last M lines will contain two space-separated integers, a_i (-10^5 \leq a_i \leq 10^5) and b_i (-10^5 \leq b_i \leq 10^5), the X and Y coordinates of a rock, respectively.

It is guarateed that no rock will ever land on top of Stacy's position at the end of the series of commands or on the space shuttle. It is possible two rocks will land on top of each other.

Output Specification

Output a single string, yes if Stacy can make it back to the space shuttle, and no if she cannot.

Sample Input

3 1
1 1
4 1
-26 1
-7 1

Sample Output

no

Explanation for Sample

At the end of the series of commands, Stacy will end up at position (-21,3). A single rock is located at position (-7,1), which will be on her trajectory back to the space shuttle. Thus, Stacy will be unable to return to the space shuttle.


Comments

There are no comments at the moment.