Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

Блог пользователя sahkumar.bishwash

Автор sahkumar.bishwash, история, 2 месяца назад, По-английски

PyPy 3-64 Submission id 261912327 Python 3 Submission id 261912035. Spent all my time debugging this code but could not figure out during contest.

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

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

Auto comment: topic has been updated by sahkumar.bishwash (previous revision, new revision, compare).

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

Inside of your solve function, these lines are technically O(n^2) since string concatenation is O(n) in python.

    ans = ""
    for i in s:
        ans += dic[i]
    print(ans) 

However, the compiler that python3 uses optimizes it to O(n) but pypy3's doesn't. I would recommend just adding each character to a list and joining them at the end with .join().