|
||||||||||
Problem F. Like A TreeTime Limit: 8000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 25 Accepted Submission(s): 2 Problem Description There are n segments on the two-dimensional plane. The two endpoints of ith segment is ($S_{x_i}$, $S_{y_i}$) and ($T_{x_i}$, $T_{y_i}$). All the segments are parallel to the x-axis or y-axis. These segments actually form a undirected graph with infinite nodes and edges. We want to know whether these segments form a tree, which means: for every pair of different points on these segments, they are connected by exactly one simple path. (In our segment-based undirected graph, a “path” is considered as a continuous infinite set of points in these segments, a “simple path” is a path that each point in the set appears only once, and two simple paths are considered to be different if and only if their corresponding point sets are different. ) Input Input is given from Standard Input in the following format: n $S_{x_1}$ $S_{y_1}$ $T_{x_1}$ $T_{y_1}$ $S_{x_2}$ $S_{y_2}$ $T_{x_2}$ $T_{y_2}$ ... ... ... $S_{x_n}$ $S_{y_n}$ $T_{x_n}$ $T_{y_n}$ Constraints 1 ≤ n ≤ 100000 -10^9 ≤ $S_{x_i}$,$S_{y_i}$,$T_{x_i}$,$T_{y_i}$≤ 10^9(1 ≤ i ≤ n), and all coordinates are integers. It is guaranteed that every segment meet exactly one of these two conditions:$S_{x_i}$=$T_{x_i}$,$S_{y_i}$=$T_{y_i}$ Output Print one line denotes the answer. If every pair of points in these n segments are connected by exactly one path, output “Yes”, otherwise “No” Sample Input
Sample Output
Source | ||||||||||
|