CP with Python Essentials

Правка en3, от Shaydiesin, 2022-05-29 12:20:15

Where to begin?

It has been a common misconception amongst Competitive Programming(hereafter CP) beginners, that Python is a slower language than C++ and they must learn C++ for CP. Some of the rumours I've come across were Python submissions giving TLE but the same algorithm implemented in C++ cleared the test cases. I intend to write this blog to clear these misconceptions and give a beginner-friendly guide for CP using Python. Before diving further it would be helpful if you are fairly aware of Python syntax.

The $$$10^8$$$ thumb rule

Before jumping in to code any question one needs to think of the logic for it. Every question is given a particular time limit within which your code needs to complete execution and your algorithm needs to be efficient to do so. The thumb rule says that for a question with a 1-sec time limit, your algorithm must perform at most $$$10^8$$$ number of operations. If the time complexity goes beyond this you will certainly get TLE.

Теги python, cp in python

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en19 Английский Shaydiesin 2022-06-01 20:58:23 303
en18 Английский Shaydiesin 2022-06-01 13:43:07 142
en17 Английский Shaydiesin 2022-05-31 14:52:34 0 (published)
en16 Английский Shaydiesin 2022-05-31 14:46:56 0 (saved to drafts)
en15 Английский Shaydiesin 2022-05-31 14:09:45 0 (published)
en14 Английский Shaydiesin 2022-05-31 14:09:05 1470 Tiny change: 'ument and st_size to return' -> 'ument and `st_size` to return'
en13 Английский Shaydiesin 2022-05-30 16:13:35 8
en12 Английский Shaydiesin 2022-05-30 16:10:21 1192
en11 Английский Shaydiesin 2022-05-30 15:04:08 55
en10 Английский Shaydiesin 2022-05-30 14:31:20 274 Tiny change: 'r loop.\n--kSKak \n' -> 'r loop.\n- - \n\n'
en9 Английский Shaydiesin 2022-05-30 14:16:19 1 Tiny change: 'he order $t10^5$.\n\n' -> 'he order $10^5$.\n\n'
en8 Английский Shaydiesin 2022-05-30 14:15:51 307 Tiny change: ' Fast I/O\n[problem' -> ' Fast I/O\\\n\n[problem'
en7 Английский Shaydiesin 2022-05-30 13:59:36 671 Tiny change: 'se `stringdecode("ut' -> 'se `string.decode("ut'
en6 Английский Shaydiesin 2022-05-30 13:23:25 311
en5 Английский Shaydiesin 2022-05-30 13:03:43 92
en4 Английский Shaydiesin 2022-05-29 13:20:07 1427 Tiny change: 'n~~~~~\n\n\n\n\n\n\n' -> 'n~~~~~\n\nFast Input/Output\n------------------\n\n\n\n\n'
en3 Английский Shaydiesin 2022-05-29 12:20:15 428
en2 Английский Shaydiesin 2022-05-29 12:11:40 549
en1 Английский Shaydiesin 2022-05-27 17:38:15 60 Initial revision (saved to drafts)