CRESCENTNINJA's blog

By CRESCENTNINJA, history, 3 years 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

| Write comment?
»
3 years ago, hide # |
 
Vote: I like it +51 Vote: I do not like it

It is slow

»
3 years ago, hide # |
← 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

»
3 years ago, hide # |
 
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

»
3 years ago, hide # |
 
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++

  • »
    »
    3 years ago, hide # ^ |
     
    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.

    • »
      »
      »
      3 years ago, hide # ^ |
       
      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!

      • »
        »
        »
        »
        3 years ago, hide # ^ |
         
        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.

        • »
          »
          »
          »
          »
          3 years ago, hide # ^ |
           
          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.

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

because

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

Why are turtles slower than Bolt?

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

Because NumPy is not a Python built-in library.

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

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

  • »
    »
    3 years ago, hide # ^ |
     
    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.