Mining Rights Division
Time limit1sMemory limit2048 MB
Given chords that split a disk and two interior points, decide whether both points can lie in regions of the same two-coloring class.
Problem
A circular plot of land contains two very valuable resources at two different locations. Because of their enormous value, many companies competed for the mining rights, but a strict screening process selected only two companies. Your company is one of the two companies that finally received the mining rights. To avoid accusations of favoritism, the government devised a fair way to divide the land between the two companies, as follows:
Rule 1 (Division by company A): Company A may divide the circular land into smaller regions using fewer than line segments. Each segment starts at one point on the circumference and ends at another point on the circumference.- Rule 2 (No shared borders): Regions that share a straight border must be developed by different companies.
- Rule 3 (Acceptance and choice by company B): Company B may accept or reject the division proposed by company A. If company B accepts, company B may choose one of the resulting regions. The remaining regions are assigned to the two companies automatically according to Rule 2.
You already know the two resource locations and . On behalf of company B, you must decide whether to accept or reject company A's division so that both locations lie in regions assigned to company B.
Given the division proposal as a set of line segments and the two resource locations, write a program that decides whether company B should accept the proposal.
Input
Input is read from standard input. The first line contains an integer , the number of segments that divide the circle, where is less than . The next lines describe the segments. Each line contains two integer indices that give the two endpoints of one segment. The circumference is divided into units. The point on the circumference that lies exactly due east of the center has index , and the index increases counterclockwise up to . No segment is duplicated. After the lines, two more lines give the resource locations and , which are different from each other. Each location is given by two integers. The first integer is the index where the ray from the center through the location meets the circumference. The second integer is the distance from the center to the resource. The radius is divided into units, so the center has distance and points on the circumference have distance . Each resource lies inside the circle and never lies on a segment.
Output
Output is written to standard output as exactly one line. Print "YES" if company B can obtain both resource locations and . Otherwise, print "NO".