Cycle
Easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
A graph is given. Determine does it contain a cycle of negative weight, and if so, print it.
Input
The first line contains the number of vertices n (1 ≤ n ≤ 100). Each of the next n lines contains n numbers - the adjacency matrix of the graph. Weights of the edges do not exceed 10000 by absolute value. If the edge is absent, the corresponding value is 100000.
Output
Print in the first line "YES", if a cycle exists, or "NO" otherwise. In the presence of the cycle output in the second row the number of vertices in it (assuming the same first and last) and the third row - tops included in this series in order of traversal. If several cycles - output any.
Examples
Input #1
Answer #1
Submissions 3K
Acceptance rate 21%