Forest plantations
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
An undirected, unweighted graph is provided.
Your task is to determine if this graph is a tree.
Input
The first line of the input contains a single natural number N (N ≤ 100), representing the number of vertices in the graph. Following this, there are N lines, each containing N numbers, which form the adjacency matrix of the graph. In the i-th row and j-th column, a 1 indicates that vertices i and j are connected by an edge, while a 0 indicates no edge between them. The main diagonal of the matrix consists of zeros, and 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 275
Acceptance rate 33%