ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1253. Necrologues

An 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.