Introduction to Competitive Programming
NOTE : This page is to act as a supplement to the content I covered in the stream. There are some points here which are very concise but are explained well in the stream because video format has its own benefits as you can’t write as fast as you speak or think.
What is Competitive Programming?⌗
- It is a mental sport like chess or GO, also referred as sport programming.
- Participant has to solve well-defined problems quickly in given duration, time and memory constraints.
- Problems are called well defined as the mathematical model of the problem, input and output data are clearly defined and don’t have ambiguity as some real world problems have.
Why to do CP? (here onwards I’ll refer Competitive programming as CP)⌗
- Here are some of the comments on the blog entries on codeforces titled Why to/you do CP? has:
- Good way to spend time if you’re jobless.
- Pick up CS concepts faster.
- Understanding and appreciating certain algorithm requires a level of algorithmic understanding, doing CP helps in getting to that level.
- Improves problem solving ability. Though it is not the only way to do so.
- Master debugging.
- Prepares you well for technical interviews.
- It’s fun and hobbies don’t need to have benefits.
What if I don’t like it?⌗
-
No need to learn it, there are many important things worth your time. Read this post on freecodecamp.
-
But this doesn’t mean that all of this is for nothing. Read this blog by vexorian regarding smug opposition to competitive programming.
-
I think one must try new things and if anything doesn’t feel good then it won’t stick with you for that long. No need to force yourself to like something.
Okay I’m interested where should I practice?⌗
-
Online contests and practice can be done at websites called online judge. Online judge is an online system to test programs in programming contest. Some great online judges (in no particular order)
-
Apart from online contests there are onsite contests too, but they also use an online judge to grade submissions. Some of the programming competitions that you should watch out for are:
How to practice?⌗
Tools you need⌗
- A text editor (you don’t need an IDE, don’t bother with codeblocks or DEV C++). I prefer vim (I’m very cool) but if you want to start I’ll recommend sublime text and there are plenty of tutorials out there explaining how to setup sublime for competitive programming.
- Working knowledge of at least one programming language that is allowed in the competition. C++, python and java are allowed almost everywhere.
- Packages for your language installed on your system for local testing.
How do I learn?⌗
- You learn by solving more problems and learning new concepts as you encounter them.
- Some resources for learning
- Some nice books
- If you get stuck somewhere
- read the tutorial, it exists most of the time.
- Ask someone you know in person or your seniors
- Ask community
What to solve? How to improve?⌗
- Basic tracks on hackerearth and hackerrank.
- CSES problemset
- Junior training sheet by Mostafa Saad
- Starred problems in CP3
- Participate in regular contests on various online judges.
- Solve at least one problem you weren’t able to solve in contest.
Further reading⌗
- A way to practice competitive programming : From rating 1000 to 2400+
- The science of training in competitive programming