abcsumits's blog

By abcsumits, history, 3 years ago, In English

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.net/contest/1675/problem/B my contest submition — https://codeforces.net/contest/1675/submission/155950529 my pypy3 submition- https://codeforces.net/contest/1675/submission/156065421 a correct submition for referrence- https://codeforces.net/contest/1675/submission/156006177

  • Vote: I like it
  • +4
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
3 years ago, # |
  Vote: I like it +3 Vote: I do not like it

yes I think u are right.

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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++

  • »
    »
    3 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    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..

    • »
      »
      »
      3 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      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.

      • »
        »
        »
        »
        3 years ago, # ^ |
          Vote: I like it +3 Vote: I do not like it

        so should i change my lang?

        • »
          »
          »
          »
          »
          3 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          If you plans for growing up in competitive programming are enough great (1600+) I think that it may be a good idea. If you take a look for the people in the top for rating you can notice that no one from them using python and it's not coincidence.

          • »
            »
            »
            »
            »
            »
            10 months ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            did i still need to change it(check out profile first, i am underperforming rn)

        • »
          »
          »
          »
          »
          3 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          At your current level that will not give your many pluses. An idea to change your lang for c++/java will help you in future when the problems you solve will be a bit more difficult. So finally the choice is yours. I can just say that there wasn't be a moment when I regretted changing the language

»
3 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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.

»
13 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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