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 1389. Roadworks

How to be fast?
Posted by Artem Khizha [DNU] 25 Jan 2011 17:19
Greetings!
I have just solved this problem with DP on a tree via DFS, but it appeared to be much too slow (0.25s), though I expected a better result. There's a tree in this problem, so totally solution must be O(N).
May any precial tricks be there or I just did something wrong?
Re: How to be fast?
Posted by Tranvick 13 Dec 2011 15:35
You need only 2 DFS. This solution get AC in 0.08s.