Armistice Negotiation
InterviewTime limit2sMemory limit512 MB
Given two sets of points, decide whether a straight line exists that keeps each country's cities strictly on opposite sides.
- Level
Medium6 of 10
- Topics
- Geometry, Divide and conquer, Brute force, Math
- Solved
- No attempts yet
Problem
Country nein invaded country sys, and sys held the attack off. The two countries now negotiate a new border. The border is a single straight line in the plane: every city held by nein lies on one side of it, and every city held by sys lies on the other side. A city that sits on the line itself is not allowed. Such a line does not always exist, so decide whether one exists.
Input
The first line contains the number of cities of nein, , and the number of cities of sys, . ()
Each of the next lines contains the coordinates and of a city held by nein.
Each of the following lines contains the coordinates and of a city held by sys.
All coordinates are integers with . No two cities share a position.
Output
Print YES if a line that fully separates the cities of the two countries exists, and NO otherwise.