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 1471. Distance in the Tree

Hint for DFS and Crash #3 !!!!!
Posted by tiancaihb 13 Jan 2010 13:33
I used Tarjan Algo, based on DFS and union-find sets, but got Crash AV #3. I made a extreme data myself, like a chain from Node #0. And it really crashed with DEV-C++. I tried to enlarge the size of stack, but it seemed workless. After debugging for so long, I still can't explain why it got stuck at Node #49xxx (The program works on every "smaller data"). Do I have to make a "stack" myself? No, I came up with an idea--randomize. And with that I ACed with no difficulty.
Here is the thing, maybe you picked Node #0 as the root of the tree, but why not change to a random one? I think data #3 is such a data that will make the first algo crash.
Sorry for my poor English, btw.
Re: Hint for DFS and Crash #3 !!!!!
Posted by Baurzhan 15 Jan 2010 22:11
I had the same problems with this problem but increasing size of the stack helped me. Post here your e-mail and i'll send you my code. I think you understand my code because i made it the same way with you(dfs+disjoint set)
Re: Hint for DFS and Crash #3 !!!!!
Posted by tiancaihb 16 Jan 2010 12:50
tiancaihbATsinaDOTcom

No, forget about it. I must have writen a wrong code
The right one is #pragma comment(linker, "/STACK:16777216").
Well, that's embarrassing because you won't get CE even if it's wrong.
I wrote before: #pragma comment(linker, "/STACK:64777216")

Edited by author 16.01.2010 12:54

Edited by author 16.01.2010 12:55