Surprising Python quirk

Правка en1, от SoleProprietor, 2023-01-07 02:47:50

I have two almost identical submissions getting a substantial difference in execution time:

TLE submission uses variable MOD inside the main function:

def main():
    MOD = 998244353  # local var
    ...
main()

and the AC submission uses variable MOD outside:

MOD = 998244353 # global var
def main():
    ...
main()

Any idea what causes such a difference in performance?

Теги python, execution time

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский SoleProprietor 2023-01-07 02:47:50 562 Initial revision (published)