Problem K
The Great Divide
Input: standard input
Output: standard output
Time Limit: 8 seconds
Memory Limit: 32 MB
Somewhere in
Majestix Cleverdix
The two chiefs have decided to divide the village into two parts by digging a straight ditch through the middle of the village so that the houses of the supporters of Majestix lie on one part and those of the followers of Cleverdix lie on the other. So, they have invited Getafix, the venerable druid of Asterix’s village, to figure out whether such a dividing line exists or not.
Getafix
Since Getafix knows that you are so good in programming, he seeks your help.
Input
The input may contain multiple test cases.
The first line of each test case contains two integers M and C (1 £ M, C £ 500), indicating the number of houses of the supporters of Majestix and Cleverdix respectively.
Each of the next M lines contains two integers x and y (-1000 £ x, y £ 1000) giving the co-ordinates of the house of a supporter of Majestix. For convenience each house is considered as a single point on the plane.
Each of the next C lines contains two integers x and y (-1000 £ x, y £ 1000) giving the co-ordinates of the house of a supporter of Cleverdix.
The input will terminate with two zeros for M and C.
Output
For each test case in the input output a line containing either “Yes” or “No” depending on whether there exists a straight line that divides the two set of houses. The dividing line can NOT contain points of both sides.
Sample
Input
4 3
100 600
200 400
600 500
300 700
400 100
600 200
500 300
4 3
100 600
400 100
600 200
500 300
200 400
600 500
300 700
0 0
Sample
Output
Yes
No
(World Final Warm-up Contest,
Problem Setter: Rezaul Alam Chowdhury)