CP - Week 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Competitive programming

Week - 1

This Doc is based on competitive programming, Which will help you in


preparation for your internships as well as placements , coding contests.

Prerequisites
For cp there are no prerequisites as such. But to start CP you will need a decent
level of knowledge of at least one programming language.

General Order of Preference :-


C++ > Java > Python > others
It isn’t that tough to switch between languages if you have a hold of at least one
language.

Setting up the IDE (Code Editor):


Two of the most popular ones are :-
1. VS Code
a. Windows
b. Mac
2. Sublime Text

Learning CPP (Skip this if u know basic cpp) :


What we are going to recommend is the fastest and the preferred way to learn
C++. These are short videos , yet they are more than sufficient. Note : Do not
waste much of your time learning the language ( getting into tiny details).
1. C++ Basics for Competitive Programming - Part 1 | CP Course | EP 2
2. Solve First 10-20 problems from here. just to get comfortable with the
language you chose.

Websites to learn :

Some websites from where you can learn and compete and some important
competitions.

Codeforces :- Most popular and widely used platform.


● Contests are mainly of 6 types:- Div 3, Div 2, Div 1, Div
1+2, Educational Rounds , Global Rounds.
● We recommend participating in all rounds without
worrying about rating changes(ratings are
temporary but experience is unique).
● Do try to solve all the problems whose ratings are
<= your rating + 300. If you are not able to solve the
problems, refer to their editorial if you still don’t
understand the solution, discuss it with your friends.

Atcoder :- Educational and Weekly contests with quality


problems.
● 3 types of contests:- atcoder beginner/regular/grand
contest
● Must participate in Atcoder Beginner Contests(100 mins a
week isn’t that much)

Codechef :-
● 3 monthly contests :- Long challenge, Lunch-time and
Cook-off
● Weekly contests named starters
After Completing the Basic Prerequisities:

After we have learnt a language, we can now get started with actual
problem solving.Problem solving requires understanding the problem statement
and designing an effective algorithm that successfully solves the task at
Hand. The efficiency of algorithms is very important in competitive
programming. Usually, it is easy to design an algorithm that solves
the problem slowly, but the real challenge is to invent a fast
algorithm. If the algorithm is too slow, it will get only partial points or
no points at all. Thus comes into picture the concept of time complexity. The
time complexity of an algorithm estimates how much time the algorithm
will take for some input. The idea is to represent the efficiency as a
function whose parameter is the size of the input. By calculating the
time complexity, we can find out whether the algorithm is fast enough
without implementing it.
Here are some resources which will help you understand time
complexity : -
1. [optional]CPH (Competitive Programmers’ Handbook) Chapter 2.
- Do read this chapter thoroughly without skipping to get a
complete understanding of Big O notation etc.
2. Big-O notation in 5 minutes
Big-O notation in 5 minutes — The basics
3. This might help you in avoiding Time Limit Exceeded error

After This You will Be ready with Basic CPP:


STL:
The Standard Template Library (STL) is a set of C++ template classes to provide
common programming data structures and functions such as lists, stacks,
arrays, etc. It is a generalised library of container classes, algorithms, and
iterators. Basic knowledge of STL is quite handy, and in fact, necessary for
competitive programming. It is the most Important thing that you have to learn
in CP.

C++ STL : Full Overview in 10 Minutes | Competitive Programming Course | E…


Best STL library explanation
Following are some practice problems :-
● Problem1
● Problem2
● Problem3
● Problem4
● Problem5
● Problem6
● Problem7
● Problem8
● Problem9

Foot note:

If you are very well with above concepts you can start doing leetcode or this
sheet [Take the topic arrays go in a sequential manner]
References for Algorithms:
1. Handbook (CPH):- You can find 90% of things you want to
learn in this book, but I would not recommend reading this book
completely and then starting solving problems. Just refer to the
book when you come across a topic which you haven’t heard
before.
2. CSES :- The author of the Handbook has also made a
compilation of 300 really good and conceptual problems which
covers almost all CP topics. But it doesn’t contain problems
sorted according to difficulty so you will have to estimate it using
solve count.
3. USACO Guide:- This is literally the “one stop shop”. This
website is generally referred to USA computing olympiad
aspirants and it has everything in sorted order. And it has
divisions like Bronze, Silver and Gold. It will mostly refer to the
Handbook and explain solutions of CSES problems also.
4. CP-Algorithms:- Contains all CP topics but again not in
sorted order of difficulty. So, refer to it only if you are stuck on a
topic and couldn’t find it in the Handbook.

You might also like