#K33172. Chef's Hideout Escape
Chef's Hideout Escape
Chef's Hideout Escape
Chef is on a mission to reach Dr. Doof's hideout without triggering any of the dangerous corridors set as traps. Each corridor is a horizontal segment defined by its starting and ending x-coordinates and placed at a fixed y-coordinate. Chef can safely traverse if his starting point and the destination are both on the same side of every corridor. In other words, for a corridor at \(y=y_i\), if Chef's starting point is \(y_s\) and the hideout is located at \(y_d\), then a dangerous crossing occurs if \(y_i\) lies strictly between \(y_s\) and \(y_d\); that is, if \( (y_s < y_i < y_d) \) or \( (y_d < y_i < y_s) \).
Your task is to determine for each test case whether Chef can reach the hideout without crossing any corridor.
inputFormat
The input begins with an integer (T) denoting the number of test cases. Each test case is described as follows:
- An integer (N) representing the number of corridors.
- (N) lines follow, each containing three space-separated integers: (x_{i1}), (x_{i2}), and (y_i), which specify a corridor spanning from (x_{i1}) to (x_{i2}) located at (y=y_i).
- A line with two integers follows, giving the coordinates (x_s) and (y_s) of Chef's starting point.
- Another line with two integers gives the coordinates (x_d) and (y_d) of Dr. Doof's hideout.
All input values are provided via standard input (stdin).
outputFormat
For each test case, print a single line to standard output (stdout) containing the string "YES" if Chef can reach the hideout without crossing any corridor, and "NO" otherwise.## sample
1
2
1 5 3
2 6 8
0 2
7 1
YES
</p>