0% found this document useful (0 votes)
30 views

CP Roadmap

Uploaded by

mahiverma.2727
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

CP Roadmap

Uploaded by

mahiverma.2727
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Roadmap to

Competitive Programming (CP)

INTRODUCTION:
➡️ What is CP?
It's a mind-sport where you are given a problem and have to develop optimised
solutions for the given constraints with your coding skills. This helps us in
building our logical and analytical thinking skills and also in enhancing our
knowledge.
Now, the question is how we can do Competitive Programming.

➡️ Various CP Platforms (Online Judge)


✧ An online judge is an online system to test programs in programming
contests.
It runs the code for test cases which are hidden and compares it with the
expected output within the memory and time limits imposed.
✧ Some Popular CP Platforms are -
Codeforces (We will see more about it further…), Codechef, Atcoder, Topcoder,
Hackerrank, Leetcode etc.
✧ Some Popular Coding Cups / Hackathons -
➢ International Collegiate Programming Contest (ICPC) - Oldest, largest
and most prestigious programming contest in the world.
➢ Hacker Cup - Facebook Meta’s annual open programming competition.
➢ ICFP - A three-day open programming competition.
GETTING STARTED:

What’s better than some advice from the best to get started?
● How to start Competitive Programming? For beginners!
● How To Become Red Coder? (codeforces.com)

➡️ Pre-Requisites -
What text editor or IDE should I use for competitive programming?
Some of you may have thought about which editor to be used for competitive
programming. Well, some of the good editors for CP are Sublime Text (for both Linux
and Windows), CodeBlocks (for Windows only), and Geany. However, if someone still
uses online editors (GeeksForGeeks, Codeforces, Ideone, or CodeChef IDE), switch to
offline editors as soon as possible. Online editors should not be used during the contests
because the site may crash at that time, and you may lose the unsaved code. Also, if you
are using Ideone or Pastebin, your code may get stolen, and you might be caught in
plagiarism.

Now talking about the offline editors, if you have Linux installed on your laptop, you
can easily set up Sublime Text on it. (Installing Sublime Text on Linux, Set Up Sublime
Text in Linux). However, if you are using Windows, try setting up Sublime Text
(Sublime Text for Windows). However, if it is giving any errors which you are not able
to resolve, then you can set up CodeBlocks easily on your system. You can also set up
Geany on your Linux system if you want.
(Linux setup for Competitive Programming (with Geany))
➡️ Week I -
✧ So, in the first week, we will start with the most essential things required
for CP, which are Learning a Language and Understanding Time and Space
Complexity.
✧ On the language part, we would be learning C++ because it’s the most
commonly used language in CP for two main reasons: a. It’s faster than any
other programming language in terms of speed, and b. It has a very vast Standard
Template Library (which we are going to cover in the upcoming weeks)

✧ BREAKDOWN -

Day I On Day-I, we will be covering the sheer basics of C++,


including the Basic Syntax, I/O and Variables.

Introduction to C++ -
- Basic Syntax and Structure
- Input/Output in C++
- Comments in C++

Variables and Data Types -


- Variables and Literals
- Fundamental Data Types in C++
- Typecasting in C++
- Scope of a Variable
- Operators in C++

Day II Moving on to Day-II we would be covering the Flow


Control in C++.
Now, what is Flow Control?
Flow control statements serve to specify what has to be
done by our program, when, and under which
circumstances. It includes Conditional Statements and
Loops.

Conditionals in C++ -
- If-Else Statements
- Switch-Case Statements
- Ternary Operator (Substitute for if-else)

Loops in C++ -
- While and do-While Loops
- For Loop
- Break and Continue statements

Day III Moving on to Day-III we would be covering the most


fundamental kind of data structure in C++ which is an
Array. We will also cover the implementation of Strings
(both C-Style and string Object).
We would also introduce you to Pointers and
Dereferencing.

Arrays in C++ -
- Introduction to Arrays
- Multidimensional Arrays

Strings in C++ -
- C-Style and C++-Style Strings
- More with string Object in C++

Pointers and Dereferencing -


- Introduction to Pointers
- Working with Pointers in Arrays
- Dynamic Memory Allocation in C++

Practice Time !!
- Reverse words in a given string
- https://codeforces.com/problemset/problem/1760/B
- https://codeforces.com/problemset/problem/1703/C
- https://codeforces.com/problemset/problem/1758/A

Day IV Moving on to Day-IV we would be wrapping up the


things in C++. Today, we will be dealing with Functions in
C++ and Recursion.

Functions in C++ -
- How to create Functions?
- Default Arguments in a Function
- Passing Array to a Function in C++
- Call by Value v/s Call by Reference

Recursion -
- Introduction to Recursion in C++
- Recursion and Backtracking
Practice Time !!
- https://www.codechef.com/problems/FIBXOR01
- https://www.geeksforgeeks.org/partition-set-k-subsets-
equal-sum/
- https://www.geeksforgeeks.org/given-a-string-print-all-
possible-palindromic-partition/

Day V It's time we move on to the various coding platforms like


Codeforces, Codechef etc. Of these, Codeforces is the
main, so we have a detailed overview for you of the judge.

For other Judges, the UI is straightforward, and a


breakdown of the rating system is provided below.
- CodeChef
- AtCoder
- HackerRank
- TopCoder

It is advised to spend some time on these platforms and


familiarise oneself so that one is comfortable with these
platforms, as these will be a constant part of the CP
Journey.

Day VI On Day-VI, we will discuss the Big-O Notation and its


relation to the CP scenario. We will get an overview of the
classification and an overview of how to judge the time
complexity of an intended solution using the constraints
of a problem.
- Introduction to Time Complexity
- Big O Notation
- Judging Constraints

Practice Time !!
- As an exercise, you can analyse the time complexity
of the problems you have solved till now and figure
out the bound of the algorithm used using the Big-
O Notation.
- Trick questions from Time & Space Complexity -
Coding Ninjas CodeStudio

Day VII Practise day? Check out the resources given below, like
ladders etc.
You guys can now do lower-rated Codeforces problems
(<1300) on A2OJ Ladders and Introductory Problems on
CSES Problem Set…
A2OJ Ladders
CSES Problem Set - Tasks
Solve C++ | HackerRank

✧ Some Extra Topics for Week I - (Depends on your interest :)


- Structs in C/C++
- Linked List and its Implementation
- Object Oriented Programming (OOPS) in C++
- Common Errors in C++

➡️ Week II -
✧ We are going to cover C++’s Standard Template Library or STL in the upcoming
two weeks (Week II and III).

✧ What is STL?
STL contains a lot of predefined functions and data structures that can be used in CP.
So it becomes important for us to learn STL to improve CP.
✧ You can go through this link to get an overview of STL.

✧ Since STL has a lot of functions and predefined data structures in STL, it can be
overwhelming to go through every one of them. So we will be covering only some of the
most useful data structures in STL that you are most likely to encounter during your CP
journey.

✧ BREAKDOWN -

Day I Iterators -
They are very similar to pointers in various ways, it might
be a little tricky to fully understand without any prior
knowledge of STL containers.
But try to read about them from this blog.
To iterate over Different containers using a Range-based
for loop in C++ provides a sleek syntax.

Day II-III Sort -


Here is a link to learn about sort in C++ - Sort

Lambda expression -
You can read about it from Lambda expression in C++ -
GeeksforGeeks.
These are useful when you want to write custom
comparator functions.

Practice Time !!
- https://codeforces.com/contest/903/problem/C
- Ferris Wheel
- Musical Rods - Problems | CodeChef
- https://codeforces.com/problemset/problem/492/B
- https://codeforces.com/problemset/problem/1545/A

Pair -
Pair is a relatively simple container, defined in STL, it is
used when we want to store two data together.
Give it a read from this blog.

Practice Time !!
- The Monk and Class Marks | Practice Problems

Day IV Vectors -

Vector is a C++ container that is used to store a particular


data type. They are very similar to the classical array but
have a lot of advantages over them.
For more on vector v/s arrays, you can go through the
Advantages of a vector over an array in C++.
Now give a read to the vectors part of this blog.

Practice Time !!
- Maximize the sum | Practice Problems
- Minimum operations | Practice Problems
- Infinite arrays | Practice Problems

Day V Binary Search, Lower Bound & Upper Bound -


Binary search is a searching algorithm in a sorted array
that exploits the sorted nature of the array and reduces
the time complexity to O(log n).
Lower bound and upper bound are functions that use
binary search in their implementation. You can see the
applications in the following articles:
- Binary Search - Algorithms for Competitive
Programming
- std::upper_bound and std::lower_bound for Vector
in C++ STL - GeeksforGeeks

Practice Time !!
- https://codeforces.com/problemset/problem/1566/A
- https://codeforces.com/group/ctEtdi2TSJ/contest/396408/p
roblem/A
- https://codeforces.com/group/ctEtdi2TSJ/contest/396408/p
roblem/E
- https://codeforces.com/contest/1370/problem/D

Day VI Stacks -
Stacks are a type of container with LIFO (Last in First
Out ) type of work, where a new element is added at one
end (top) and an element is removed from that end only.
You can refer to this article to learn about syntax and
basic functionalities in the stack.

Practice Time !!
- Parenthesis Checker | Practice | GeeksforGeeks
- https://practice.geeksforgeeks.org/problems/next-larger-
element-
1587115620/1?page=1&category[]=Stack&sortBy=submissions
- Longest valid Parentheses | Practice | GeeksforGeeks

Day VII Practice Time !!


- https://codeforces.com/problemset/problem/1183/D
- https://www.geeksforgeeks.org/the-stock-span-problem/
- https://codeforces.com/group/ctEtdi2TSJ/contest/384123/p
roblem/H
- https://codeforces.com/group/ctEtdi2TSJ/contest/396408/p
roblem/E
- https://codeforces.com/problemset/problem/1201/C
➡️ Week III -
✧ BREAKDOWN -

Day I Queue -
Queue is a type of container adapter that operates in a first in
first out (FIFO) type of arrangement.
More about the queue here and in this blog.

Practice Time !!
- First negative integer in every window of size k | Practice |
GeeksforGeeks
- Disk tower | Practice Problems

Day II - III Map, Unordered-map, Multimap, Unordered_multimap -

You can go through different map operations in this blog.


Map - Map in C++ Standard Template Library (STL) -
GeeksforGeeks
Unordered_map - unordered_map in C++ STL -
GeeksforGeeks
Multimap - Multimap in C++ Standard Template Library
(STL) - GeeksforGeeks
Unordered_Multimap - unordered_multimap and its
application - GeeksforGeeks

Practice Time !!
- https://codeforces.com/contest/4/problem/C
- Subarray with 0 sum | Practice | GeeksforGeeks
- Sum of Two Values
- CSES - Subarray Sums I

Day IV- V Sets, Unordered_set, Multiset, Unordered_Multiset -

Set - Set in C++ Standard Template Library (STL) -


GeeksforGeeks
Unordered_set - Unordered Sets in C++ Standard Template
Library - GeeksforGeeks
Multiset - Multiset in C++ Standard Template Library (STL)
- GeeksforGeeks
Unordered_multiset - Unordered_multiset and its uses -
GeeksforGeeks

Practice Time !!
- Twice Counter | Practice | GeeksforGeeks
- https://codeforces.com/contest/855/problem/A
- https://atcoder.jp/contests/arc087/tasks/arc087_a?lang=en
- Monk and the Magical Candy Bags | Practice Problems
- https://www.geeksforgeeks.org/largest-subset-of-array-
having-sum-at-least-0/

Day VI Priority Queue -


Priority queues are containers similar to queue, but the only
difference is that the top element is always the maximum of
the set.
Priority queues are implemented internally using binary
search tree. So insertion and deletion are O(log n).
Read more about priority queues in this blog.

Practice Time !!
- Monk and the Magical Candy Bags | Practice Problems
- K-th Largest Sum Contiguous Subarray | Practice |
GeeksforGeeks

Day VII Remember, When in doubt, always refer to:


Cppreference.com

Now you can create a Template code for yourself


But wait,
What are template codes? How Should I create one for
myself?
Templates are some pre-written code that competitive
programmers use to make their Coding faster and more
efficient.

For example, take this Sample Template


To understand this Template better, you can go through this
doc.

Now, that you know a lot of stuff so you are a lot more likely
to make a lot of mistakes so here is a video that would be of
great help
C++ Mistakes Noobs Make (and how to prevent them)

By now you are well familiar with C++ STL, so you will be
better able to appreciate this blog and use it: C++ tips and
tricks - Codeforces.

➡️ Week IV -
✧ So, in the fourth week, we will be covering some miscellaneous topics
that are very much essential as you proceed higher up in the domain of
Competitive Programming.
✧ The topics include - Prefix Sums, Number Theory, Dynamic
Programming and Bit Masking.
✧ This section is more about practice, the content would be very minimal,
but you can improve your grip on these topics by practising more and
more…

✧ BREAKDOWN -

Day I Prefix Sums -


- Prefix Sums

Practice Time !!
- Problem 2. Hoof, Paper, Scissors
- Power of Points
- Forest Queries
- Problem 2. Subsequences Summing to Sevens

Day II Number Theory -


- Number Theory
- Sieve of Eratosthenes - GeeksforGeeks (useful for
finding primes quickly in a range)
- Modular Inverse - Algorithms for Competitive
Programming

Practice Time !!
- CSES - Exponentiation II
- CSES - Counting Divisors
- CSES - Sum of Divisors
- https://codeforces.com/contest/1349/problem/A
- https://codeforces.com/contest/1758/problem/D
- https://codeforces.com/contest/1811/problem/D

Day III Bit Masking -


- Bit Manipulation
- CF Blog - Bitmasks for beginners

Practice Time !!
Try implementing addition and multiplication using bitwise
operators only (you can use
loops)https://codeforces.com/problemset/problem/1514/B
- https://codeforces.com/problemset/problem/1615/B
- https://codeforces.com/contest/1758/problem/B
- Counting Bits
- Maximum Xor Subarray
- https://codeforces.com/contest/1207/problem/E
- https://codeforces.com/contest/276/problem/D
- https://codeforces.com/problemset/problem/1614/C

Day IV - V Dynamic Programming -


- DP - From Novice to Advanced
- More Resources for DP

Practice Time !!
It is an excellent idea to solve the entire CSES ‘dynamic
programming’ section (except the last 2-3 questions).
Some selected problems are given below:
- Coin Combinations I
- Coin Combinations II (contrast with the previous problem)
- Two Sets II
- https://codeforces.com/problemset/problem/455/A
- Longest Common Subsequence - LeetCode
- CSES - Projects
Sliding Window -
Day VI - Sliding Window Technique

Practice Time !!
- https://codeforces.com/problemset/problem/279/B
- https://cses.fi/problemset/task/1077
- https://cses.fi/problemset/task/1076

DAY VII Practice Time !!

Here are some questions for your practice:


- https://codeforces.com/problemset/problem/1234/C
- https://codeforces.com/contest/1557/problem/B
- Problem 1. Sleepy Cow Herding
- https://codeforces.com/contest/1529/problem/B

➡️ Week V -
✧ So, in the five week, we will be covering some advanced data structures
topics that are very much essential as you proceed higher up in the domain
of Competitive Programming.
✧ The topics include - Basic Graph Theory, Trees and Segment Trees.
✧ This section is more about learning , there week will be containing heavy
learning, but you can improve your grip on these topics by practising more
and more…

✧ BREAKDOWN -

Day I Introduction to graphs -


- https://www.geeksforgeeks.org/graph-types-and-
applications/
- https://www.youtube.com/watch?v=gX EDmodO
J&t=899s&ab_channel=mycodeschool
- Difference between Graph and Trees

Day II Implementation of graphs-


Firstly, we will be looking at the implementation of
graphs in C++.
- Graph Representation
- Graph Representation Video
Practice Time !!
- https://codeforces.com/problemset/problem/292/B
- https://codeforces.com/problemset/problem/1829/F

Day III-IV Graph Traversal Algorithms-


Now we are going to learn how to traverse through a
graph.

Breadth First Search -


- Lecture on BFS
- Cp Algorithms

Day V Depth First Search -


- Lecture on DFS
- Cp Algorithms

If you are still struggling to get an intuition for these


algorithms you can check these resources might help you.

- William Fiset
- Reducible
Practice Time !!
- https://atcoder.jp/contests/abc315/tasks/abc315_e
- https://codeforces.com/problemset/problem/1843/D
- https://codeforces.com/problemset/problem/1830/A
- https://codeforces.com/problemset/problem/1143/C

DAY VII Segment Tree-

This is a relatively hard data structure for beginners. This data


structure is required generally for problems of rating >= 1800.
- Course by ITMO University
- Cp Algorithms Segment Tree
Note : Only Cover the starting portions of the Cp Algorithms
Segment Tree Section.
Do try the questions given in the ITMO University course as they
contain all the standard uses of Segment Tree.
Practice Time !!
These are some of the easy questions from the practice problems
section of cp algorithms.
- https://codeforces.com/problemset/problem/339/D
- https://codeforces.com/problemset/problem/1234/D
- https://codeforces.com/contest/356/problem/A
- https://cses.fi/problemset/task/1735

➡️ Some More Resources -


✧ Books -
● Competitive Programmer’s Handbook | CSES
● Guide to Competitive Programming | Springer
✧ Problem Sets and Resources -
● CSES Problem Set
● A2OJ Ladders
● CP-Algorithms
✧ Blogs -
● Blog: From Rating 1000 to 2400+
● Blog: From Rating 1000 to 2000
● 75 LeetCode Questions to save your time
✧ YouTube Channels -
● Errichto Algorithms- He has educational videos of various useful topics like
dynamic programming, binary exponentiation and other useful topics.
● William Lin- He has done a live stream of the full cses problem set which some
of you might find helpful. He also has screencasts of various codeforces and
codechef rounds.
✧ Miscellaneous-.
● Video about how to debug your code efficiently
● Codeforces Blog on Debugging
✧ Websites and Extensions-
● AtCoder Problems- This site contains a collection of all the problems on
atcoder according to their rating. Similar to A2OJ Ladder.
● Contest Mania- This site might be helpful when you are trying to find a contest
that you didn’t solve so that you can give it as a virtual contest. Just login your cf
id on the bottom left corner.
● Carrot- This extension contains everything like what was your actual
performance in the contest, how many rating points you will gain after the
contest, etc.
● CF Analytics- This extension displays the number of problems solved per rating
and links to unsolved problems.This also shows number of problems solved per
topic as well.

Contributors -
● Sanat Goel | 9779589799
● Vipul Chanchlani | 9462150839
● Goutam Das | 9827708951
● Rishi Agarwal | 7071377085
● Varun Tokas | 9990825216
● Shivam Mishra | 8604397668
● Chayan Kumawat | 9569426190
● Prerak Agarwal | 8528203343
● Sankul | 9315719561

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy