Baobab
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 256 megabytes
Given an undirected, unweighted graph, your task is to determine whether it is a tree.
Input
The input begins with 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 about the main diagonal.
Output
Print "YES" if the graph is a tree; otherwise, print "NO".
Examples
Input #1
Answer #1
Submissions 332
Acceptance rate 36%