|
|
back to boardAn interesting problem... Posted by Neumann 12 Feb 2005 10:41 DFS will work. At first,I just see if length >1000000 but got ML. I realize that the depth is too large.It has an improve, just use dfs without recursion. But there is a more simple way: It is clear that if the depth>n,there must be a cycle. So just recursion dfs can easily get AC. My pascal pro AC in 0.281sec 159 КБ and shorter than 1K. Maybe inrecursion will faster,but it is no need to do so... Is there any way else to solve this problem?I am glad to learn more algorithm. |
|
|