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 (int)
before E[u].size()
in the function hang()
and ran it on 12th test again. Surprisingly, stack did not overflow this time.
Can anyone who gets this stuff tell why this happens?