当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3964:Find The Simple Circle

题目描述
Given a directed graph, your task is to find the simple circles. The simple circle is a subgraph meeting the following conditions:

1. There are m ( m > 1 ) different vertexes and arcs in it.

2. The simple circle can be represented as a seqence "v1,v2...vm" and v1,v2...vm are different vertexes in it. There is an arc from the i-th vertex to the (i+1)-th vertex or from the m-th vertex to the 1st vertex in the simple circle.

You will be given the adjacency matrix of the directed graph, what you should do is outputing all the simple circles in it in lexicographic order. The output format of one simple circle is a string where the i-th character is the index of the i-th vertex in the simple circle seqence. To unify the format, the 1st vertex should be the vertex with smallest index. Vertexes are indexed from 0. A sequence a1,a2...ak appears in lexicographic order before a sequence b1,b2...bk if and only if the first ai, which is different from bi, is less than bi.
输入解释
There are several test cases in the input. Each case begins with a line with an integer N (2 ≤ N ≤ 9), denoting the number of vertexes in the graph. In the following N lines with N integers, the j-th number in the i-th line will be 1 or 0, representing that there is an arc from the i-th vertex to the j-th vertex or not. It is ensured that the i-th number in the i-th line is 0. Input is terminated by EOF.
输出解释
Output one simple circle sequence in one line, and end each case with a blank line.
输入样例
3
0 1 1
1 0 1
1 1 0
4
0 1 0 1
1 0 1 0
1 0 0 1
1 0 1 0
输出样例
01
012
02
021
12

01
012
0123
03
032
23
来自杭电HDUOJ的附加信息
Recommend

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3964

最后修改于 2020-10-25T23:08:49+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)