Python Runtime Error, but C++ Accepted – Why? (Mortal Kombat Tower – 1418C)

Revision en1, by iib2022029, 2025-02-08 22:00:44

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!

Tags dp, python, c++

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English iib2022029 2025-02-08 22:00:44 1123 Initial revision (published)