Hello Codeforces community,
I've been focusing on solving problems related to trees and depth-first search (DFS) recently. However, I've encountered a recurring issue when submitting my solutions. Specifically, my Python solutions often result in runtime errors on certain test cases, while the equivalent C++ code works perfectly.
For instance, consider the following submissions:
Problem 1: C++ code Python code
Problem 2: C++ code Python code
In both cases, the Python code shows runtime errors on random test cases (such as 3 or 9), while the C++ code does not.
Has anyone else experienced similar issues? If so, what strategies or modifications did you employ to resolve them? Any insights or suggestions would be greatly appreciated.
Thanks in advance for your help!
Default maximum recursion depth in python is ~1000. You can use this (some help in the blog below) to fix it, but the best way would be just avoiding recursion
https://codeforces.net/blog/entry/80158
Thanks for the link, it worked :)