A_Bored_Dog's blog

By A_Bored_Dog, 4 weeks ago, In English

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!

  • Vote: I like it
  • 0
  • Vote: I do not like it

4 weeks ago, # |
Rev. 4   Vote: I like it +1 Vote: I do not like it

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