Graph Theory 3

View as PDF

Submit solution

Points: 7
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

Given a tree of \(N\) nodes, print Graph Theory! if it is possible to visit each node from every other node with less than or equal to \(K\) nodes in between (inclusive of starting and ending nodes), and NO U otherwise.

Input Specification

The first line will contain two integers, \(N, K\ (1 \le N \le 10^5, 0 \le K \le N)\).

The next \(N-1\) lines will each contain two integers, \(a, b\ (1 \le a, b \le N)\), meaning nodes \(a\) and \(b\) are connected. It is guaranteed the entire tree is connected.

Output Specification

Print Graph Theory! if it is possible to visit each node from every other node with less than or equal to \(K\) nodes in between (inclusive of starting and ending nodes), and NO U otherwise.

Sample Input

5 4
1 3
2 3
5 4
4 3

Sample Output

Graph Theory!

Comments

There are no comments at the moment.