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

Автор abcsumits, история, 5 лет назад, По-английски

i have submitted the code in contest and it was accepted(even the solution was not hacked) and when i submitted the same code in pypy3 it was accepted.Then i saw others solution i found that everyone was having same complexity as me and submitted in python 3 only and their solution was accepted. question- https://codeforces.me/contest/1675/problem/B my contest submition — https://codeforces.me/contest/1675/submission/155950529 my pypy3 submition- https://codeforces.me/contest/1675/submission/156065421 a correct submition for referrence- https://codeforces.me/contest/1675/submission/156006177

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

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

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

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

yes I think u are right.

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

It seems that you are right, and the only conclusion from this is the idea that python language isn't the best choice for competive programming. You can use it but sometimes such interest things will happen. That's the reason why I changed my lang from python to c++

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    but the same solution of someone else has been accepted in python.(he hasnt use stdin i/o method and i have used stdin method which means my code is faster than accepted one..) i have mentioned that solution..

    • »
      »
      »
      5 лет назад, скрыть # ^ |
      ← Rev. 2  
      Проголосовать: нравится 0 Проголосовать: не нравится

      You are right and your words are just this reason. Python code is enough slow and some little difference in two solutions can be the reason that one of them will be accepted and the second will not. You can do nothing this such fact — if your are using python in some cases you will get TLE just because you are using python. It's not so noticeably when the problems are not hard but when you will solve harder and harder problems the number of problems with python will grow up so you will be forced to use c++/java instead of python. What lang to use is your choice I just tell you that the only problem of this situation is python, yeah.

»
5 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

The other persons Python3 solution ran in 1996 ms / 2000 ms. Even submitting that exact code again could very likely get TLE. I would not call a solution that runs in 1996 ms / 2000 ms "a correct submition for referrence".

I would also like to note that your code uses l[i]=l[i]//2 and the code you linked uses q = q//2. In Python repeatedly indexing a list is pretty expensive, it is not free like in C++. So I think your implementation is significantly slower than the 1996 ms / 2000 ms solution.

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

You can use this code to make I/O faster, I used to use python and had no problem whatsoever in speed. I recently changed to c++ and I do not really regret it. C++ is not "that hard" to learn.

Code