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 1752. Tree 2

TLE Test 5
Posted by Prabhjot Singh 25 Jan 2010 07:27
my algorithm is quite simple and i dont know how to make it fast. my hints would be appreciated.

1. i am using dfs to get the distance from vertex v to vertex u such that dist(v, u) = d given.

2. while computing the vertex u..i am saving the result of all previous vertices u1, u2, ....ud..such that distance between v and u1 is 1, v and u2 is 2 and so on. i am saving the result in hashmap.

3. i only use dfs if the hashmap doesnt contain the query.

I can email my code as well....

Thanks