logo AlgoBeat OnlineJudge
登录 注册

#203652. [BalticOI 2011] Tree Mirroring (Day2)

内存限制:250 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Let be a rooted tree (a connected undirected acylic graph), and let be a perfect copy of . Construct a new graph by taking the union of and , and merging the corresponding leaf nodes (but never the root). We call such a graph a tree-mirrored graph.

输入格式

The first line of input contains two integers and , the number of vertices and edges of a graph . The vertices in are labeled from to . The following lines describe the edges. Each such line contains two integers and , describing one edge. There will be at most one edge between any pair of vertices.

输出格式

The first and only line of output should contain the string YES if the graph is a tree-mirrored graph, and NO otherwise.

样例

样例输入 1

7 7
1 2
2 3
3 4
4 5
5 6
6 7
7 1

样例输出 1

NO

样例输入 2

6 6
1 2
2 3
2 4
3 5
4 5
5 6

样例输出 2

YES

样例输入 3

22 28
13 8
8 1
1 22
1 12
1 14
13 18
13 4
4 20
20 7
13 15
15 3
15 9
9 16
9 19
22 5
12 5
14 5
5 11
11 6
18 6
7 10
10 17
17 6
3 21
21 6
16 2
19 2
2 21

样例输出 3

YES

数据范围与提示

对于 的数据,。

对于 的数据,。

对于所有数据,。