Illustration of Sample Input 4. The green subgraph is
, the brown
subgraph is ,
and the edges between and are dashed. The answer is
because
is as large as
possible and .
You are conducting a study on the health of Calgary’s trees.
Your assistant has spent years collecting data for your
study, and now it’s finally time to utilize it! You would like
to figure out how healthy the trees are by analyzing how large
the canopy of each tree is. Every tree in Calgary has been
described as an undirected graph where the canopy is
represented as a clique, i.e., every vertex in the canopy is
adjacent to every other vertex in the canopy. Formally, the
graphs are described as follows:
Given an undirected graph and some , we define . In other words, contains the vertices in
along with all of the
edges that have both endpoints in . A tree canopy graph is a simple undirected graph where
the vertices can be
partitioned into two sets and such that all of the following
conditions hold:
-
is a
clique.
-
is a tree in
which every vertex has degree at most three.
-
Each leaf of
(i.e., each vertex with degree one in ) is adjacent to at most one
vertex in (but
vertices in may be
adjacent to more than one leaf in ). Apart from these edges,
there are no other edges between and .
Your assistant may have made some mistakes, so the graphs
are not necessarily all tree canopy graphs. Given a graph
, determine if
is a tree canopy
graph, and if it is, find the largest possible size of
in any valid partition
of into and .
Input
The first line of input contains two integers and (where and ) describing the
number of vertices and edges in , respectively. The next
lines each contain two
integers and
(where ) indicating that
there is an edge between vertices and in . No edge will appear more than
once in the input.
Output
If is a tree canopy
graph, output “yes ” where is the largest possible size
of . Otherwise, output
“no”.
Sample Input 1 |
Sample Output 1 |
6 4
0 1
0 3
0 4
3 5
|
yes 1
|
Sample Input 2 |
Sample Output 2 |
6 7
0 4
0 5
1 3
1 5
2 3
2 5
3 4
|
yes 2
|
Sample Input 3 |
Sample Output 3 |
6 6
0 3
0 5
1 4
1 5
2 4
3 5
|
yes 3
|
Sample Input 4 |
Sample Output 4 |
11 18
0 2
0 5
1 6
1 9
2 4
2 9
3 5
3 6
3 7
3 8
4 6
5 6
5 7
5 8
6 7
6 8
7 8
9 10
|
yes 5
|
Sample Input 5 |
Sample Output 5 |
3 0
|
no
|
Sample Input 6 |
Sample Output 6 |
6 14
0 1
0 2
0 3
0 4
0 5
1 2
1 3
1 4
1 5
2 3
2 4
3 4
3 5
4 5
|
no
|
Sample Input 7 |
Sample Output 7 |
4 3
0 1
0 2
0 3
|
yes 0
|