Today, I was checking the official solution for problem grassplant of USACO 2011 December Contest. I ran the solution on 12th test and it gave me runtime error (segmentation fault). I realized it was caused by stack overflow. Then (somewhy) I added
E[u].size() in the function
hang() and ran it on 12th test again. Surprisingly, stack did not overflow this time.
I tried doing it several times, and the code without
(int) always run out of 8Mb of stack memory and the code with it used less than 8Mb of stack memory.
Can anyone who gets this stuff tell why this happens?