I have just solved this great problem: http://codeforces.net/problemset/problem/429/A
I have solved the problem by using DFS on the given tree, like most others did, and like the editorial suggests.
As I was coding the solution, I was sure that I would get a stack-overflow, and then I would reimplement the solution using BFS. But I did not..
In the problem, it is very possible that the tree is a path (a unary tree where each node has at most one child), and its depth could be 10^5. In fact the test case #2 is a path.
A stack of depth 10^5 should be an overflow right? I have not used any linker settings to increase the stack size.
So what I'm wondering is: is it just a missing test case? Or does codeforces compilers do something special so that we don`t get a stack overflow even at depth 10^5?
I`m wondering this, because lots of times, it is easier to code the recursive DFS solution than iterative BFS solution. If possible I wish not to care about the stack-overflows.
Thank you in advance.