Is it a Tree?
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
An undirected graph without loops and multiple edges is given by an adjacency matrix. Determine whether this graph is a tree.
Input
The first line contains the number of vertices in the graph. Then, an adjacency matrix of size is given, where indicates the presence of an edge, and indicates its absence. The matrix is symmetric with respect to the main diagonal.
Output
Print "YES" if the graph is a tree, and "NO" otherwise.
Examples
Input #1
Answer #1
Submissions 17K
Acceptance rate 31%