CRESCENTNINJA's blog

By CRESCENTNINJA, history, 12 months ago, In English

Why don't they allow me using NUMPY? and why are the libraries of C++ allowed, if python is not allowed?

  • Vote: I like it
  • -9
  • Vote: I do not like it

»
12 months ago, # |
  Vote: I like it +51 Vote: I do not like it

It is slow

»
12 months ago, # |
Rev. 2   Vote: I like it +2 Vote: I do not like it

Cpp with STL is 9x faster than Python. But writing python code is very easy

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

Practically all problems < 2200 can be solved using python (and not like 1996/2000 ms.) Of course you must use FAST IO and use pypy_64

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

I do CP mostly in Python but sometimes I have to switch to C++ because I know the same code which gave a TLE in Python would sometimes give an accepted solution in C++.

Most recent experience:

212573964 Python for 1846A

212577305 C++ for 1846A

It's like the exact same code in two different languages. It happened quite a few times. So, if you are just starting to do CP, I suggest starting with C++

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

    I copied your python code and submit it as Python 3 (not PyPy 3-64) and it was Accepted (took only 734ms) 213292103. Somehow Python 3 runs faster than PyPy 3-64.

    • »
      »
      »
      12 months ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      Add the following code at the top:

      import sys

      input = lambda: sys.stdin.readline().rstrip() # faster!

      • »
        »
        »
        »
        12 months ago, # ^ |
          Vote: I like it +1 Vote: I do not like it

        Yeah, I know it works. In fact I submitted a solution later with these lines added. But my point just is that it's a very simple problem with direct implementation and it should have worked without using sys for fast input. This is the first time I encountered something like this in an 800 problem.

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

          Just tested it without the fast input, and you are right. I suspect that this might have to do with the fact that the input is split across many lines rather than a few long lines. Not ideal for an A problem indeed, especially in a D3 round.

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

because

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

Why are turtles slower than Bolt?

»
12 months ago, # |
  Vote: I like it +9 Vote: I do not like it

Because NumPy is not a Python built-in library.

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

good question, i'd like to have numpy and scipy allowed.

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

    In that case, they may at least add support for Eigen, which is a C++ library for linear algebra.