F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Problem F. Like A Tree

Time 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
5 3 0 1 0 0 0 2 0 2 0 2 2 2 2 0 2 0 2 0 1 4 0 0 2 0 2 0 2 2 2 2 0 2 0 2 0 0
 

Sample Output
Yes No
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 17:34:23, Gzip enabled