|
|
|
Assume we have a network of computers, where each computer is connected
with others by means of cables. Each cable connects exactly two computers,
and two computers can be connected to each other by only one cable.
Given a network of computers you are requested to determine all the cables
that participate in a cycle. Also, for each cable you must determine the
number of cycles in which this cable participates. A cycle is a sequence
of cables, starting from computer A and leading to itself. However, each
computer, other than A, in the cycle, should participate only once.
INPUT
Your program should read the input from the file INPUT.TXT as follows.
The first line contains a positive integer number N (N<=20) denoting the
number of computers in the network. The next N lines describe the computer
connections in a matrix form. Thus, each line has N elements, separated by a
space character. If an entry in line L and column C is 0, this means that
there is no direct connection between computers L and C. Otherwise there
is a direct connection between them.
OUTPUT
Your program should write the output into the file OUTPUT.TXT as follows.
The first line contains a positive integer denoting the number M of cables
that participate in at least one cycle. Then, one line follows, containing
a sequence of M positive integer numbers (separated by a space character)
representing the number of cycles that each cable participates in.
This sequence must be sorted in increasing order. If there is no cable that
participates in cycle(s), the output file should contain a single line
with the string "NO CYCLE".
EXAMPLE 1
| INPUT.TXT |  | OUTPUT.TXT |
6
0 1 1 0 0 0
1 0 1 1 0 0
1 1 0 0 0 1
0 1 0 0 1 0
0 0 0 1 0 1
0 0 1 0 1 0
|
|
7
2 2 2 2 2 2 2
|
EXAMPLE 1
| INPUT.TXT |  | OUTPUT.TXT |
4
0 1 0 0
1 0 1 0
0 1 0 1
0 0 1 0
|
|
NO CYCLE
|
TIME LIMIT PER TEST: 2 seconds
|