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

Автор iib2022029, история, 6 часов назад, По-английски

Hey everyone,

I was solving the problem Mortal Kombat Tower (1418C)(https://codeforces.me/contest/1418/problem/C) and wrote my solution in Python first. However, when I submitted it, I got a Runtime Error on Test Case 3.

Feeling stuck, I randomly decided to convert the same logic into C++ and submitted it... And guess what? It got accepted!

Now, I'm really confused! How did the same logic work in C++ but fail in Python?

Here are my submissions: Python Code (Runtime Error ): 305031310
C++ Code (Accepted ): 305032334

What could be the reason? I have a few possible guesses: 1. Integer Overflow or Recursion Limit in Python 2. Differences in Default Recursion Depth (C++ vs Python) 3. Memory Usage Differences 4. Unintentional Indexing Issues in Python

But I'm still not sure! If anyone can analyze my submissions and explain what went wrong, I’d really appreciate it.

Thanks in advance!

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

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

I took your submission and added a exception printer. link. It prints RecursionError('maximum_recursion_depth_exceeded') on test 3.

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

In python you can't do recursion because there is a limit (there is a way to bypass it but i don't know how ). You should do dfs with stack instead