tom's blog

By tom, 10 years ago, In English

Hello everyone,

I started learning Python few days ago and I encountered issue during solving problem from Div2. Look at these submissions:

10232811

10232825

They second one differs with one line: sys.setrecursionlimit(10000)

Without it first submission gets RTE on test #19.

Is it my fault, bug in CF or something else?

  • Vote: I like it
  • +2
  • Vote: I do not like it

»
10 years ago, # |
Rev. 2   Vote: I like it +24 Vote: I do not like it

n*m = 50*50 = 2500. If you start at the top left and go recursively through all cells then your depth can reach 2500. Python by default has recursion depth limited to 1000 and it throws the max recursion depth exceeded once you try to go deeper. By setting the recursionlimit higher you allow him to go on.