Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя Samyak_cool

Автор Samyak_cool, история, 7 месяцев назад, По-английски

During the recent contest, I was solving F and faced run time error on Test — 6, where recursion stack limit exceeded the default 1000 limit set by python. I tried to increase it using sys.setrecursionlimit but it was of no use. Please tell how to increase recursion stack limit. Here is my submission — 246218059, Submission link

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
7 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

One can use sys.setrecursionlimit(n). I cheesed some problems in Uni this way.

Your code can be run through priority queue tho. In python it's way more efficient than increasing the recursion stack.

Your code is also hella sus, if you know what I mean. What's up with the comments?

  • »
    »
    7 месяцев назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    checkCycle code is from a standard source I picked from internet. Also according to some other blogs in code forces, sys.setrecursionlimit(n) doesn’t work.

    Will check on implementing it through priority queue.

»
7 месяцев назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

use c++

»
7 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I don't trust python for recursion.