#P6722. Bipartite Tree Transformation
Bipartite Tree Transformation
Bipartite Tree Transformation
Given an undirected tree with (n) nodes (numbered from (1) to (n)) and (n-1) edges, and a constant (k), construct a new graph with the same vertex set in which there is an undirected edge between vertices (u) and (v) if and only if (dis(u,v) \ge k), where (dis(u,v)) denotes the length of the shortest path between (u) and (v) in the tree. 0x3 Miaojiang believes that if this new graph is bipartite then Ciste "has solution", otherwise Ciste "has no solution". Your task is to determine whether the new graph is bipartite.
Note: A graph is bipartite if its vertices can be divided into two disjoint sets such that no edge connects vertices within the same set.
inputFormat
The first line of input contains two integers (n) and (k). Each of the next (n-1) lines contains two integers (u) and (v), denoting an edge between nodes (u) and (v). It is guaranteed that the given graph is a tree.
outputFormat
Output a single line: if the new graph is bipartite, print "Yes"; otherwise, print "No".
sample
3 1
1 2
2 3
No