### kingofnumbers's blog

By kingofnumbers, history, 6 years ago,

hello guys

I was trying to solve problem EAGLE1 in spoj OJ

the problem gives you a weighted tree and ask you for each node , find farthest node from it

this is very standard dp problem but my code strangely always take runtime error , although I tried different coding styles.

I thought maybe there's something wrong with test cases but I tried to write code that check the validity of test case before processing it but it showed that nothing wrong with the test cases

I'm seeking for help to explain what's happening , here's my code

• +5

 » 6 years ago, # |   0 looks like a stack overflow
•  » » 6 years ago, # ^ |   0 Does spoj have stack size limit?
•  » » » 6 years ago, # ^ |   0 I have got the same problem while implementing HLD. Try a non-recursive dfs, it works for me
 » 6 years ago, # |   +3 Adding #pragma comment(linker, '/STACK:200000') to the top of your code gets it accepted :P
•  » » 6 years ago, # ^ |   +3 I've always thought that spoj doesn't limit stack size, thank you for help :)
•  » » » 6 years ago, # ^ |   +2 Did not know either!
 » 3 years ago, # |   -8 I'm stuck on this problem. Any hint for me?
 » 14 months ago, # |   -22 Can anyone explain the solution how r we using dp in this question? why greedy won't work?
 » 13 months ago, # |   +1 Can someone please help me find out where I am wrong code . Thanks in advance