Are trees?

A graph is a set of vertices (also called nodes) and a set of edges
among the vertices. A tree is a connex graph without cycles. (A general
tree is not more than a tree for which a node has been fixed as root,
and where the children of each node are sorted from the left to the
right.

(To see an instance with the first graph of the input-output instance,
consult the pdf or ps version of this wording.)

Write a program that decides if various given graphs are trees or not.
For comfort, we will suppose that the n vertices of a graph are numbered
0, 1, …, n − 1.

Input

Input starts with the description of various graphs. n lines follow,
each one with the number of neighbours of the vertex i-th followed by
these neighbours in any order. In all the graphs there is not repeated
edges nor edges from a vertex to itself.

Output

For each given graph, your program must print a line that indicates if
it is a tree or not.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:16:51.700Z

© Jutge.org, 2006–2026.
https://jutge.org
