#P8655. Detecting Cycle Nodes in a Network
Detecting Cycle Nodes in a Network
Detecting Cycle Nodes in a Network
There are N computers labeled from 1 to N. Initially, these computers were connected by N-1 data links forming a tree structure, meaning there is exactly one unique path between any two computers.
However, during a recent maintenance, an extra data link was accidentally added between two computers. This additional link created a cycle within the network. Computers on that cycle may experience data transmission bugs because there might be more than one path between any two computers in the cycle.
Your task is to identify all the computers that lie on this cycle.
Note: The formulae in the description are in LaTeX format, for example, the number of computers is given as \(N\) and the number of links in a tree is \(N-1\).
inputFormat
The input consists of N+1
lines. The first line contains a single integer N
(the number of computers). Each of the following N
lines contains two integers u
and v
indicating there is a data link between computer u
and computer v
.
outputFormat
Output the labels of all computers that are part of the cycle, sorted in increasing order in one line, separated by a space.
sample
3
1 2
2 3
3 1
1 2 3
</p>