Section 0 : Introduction
Section 1 : Basic Theory
Section 2 : Intermediate
Section 3 : Advanced
Section 0 : IntroductionSection 1 : Basic TheorySection 2 : IntermediateSection 3 : AdvancedIntroductionNumber TheoryAdvanced MathsString HashingGetting StartedTwo Pointers / Sliding WindowsRange Update QueriesDirected Graphsbasic prob solvingRange QueriesGraph Theory BasicsRange UpdateTime ComplexityDivide and ConquerDSU + MSTSparse TableIntro To STLIntro to Greedy AlgorithmsShortest pathTree AlgorithmSortingDynamic ProgrammingBinary SearchInteractive ProblemsBit OperationsNumber TheoryRecursionComplete Search
Section 0: Introduction :
Complete Search
Primary Number Theory
Binary Search
Recursion
Bit Operations
Sorting
Intro To STL
Time Complexity
basic prob solving
Getting Started
SECTION 0 part 2
SECTION 0 part 1
What is CP and Why do it?
- It's a mind-sport where you are given a problem and have to come up with optimized solutions for the given constraints with your problem-solving skills and implement with your coding skills.
- We do it because it helps us in building our logical and analytical thinking skills and also in enhancing our knowledge. But most importantly, because it’s a lot of fun! (and it helps get a job 👀)
- Some Popular CP Platforms are
- - Codeforces
- - Codechef
- - Topcoder- Atcoder
- - Leetcode
- - Hackerrank
- We will look into them further as we go on!
➡️Getting Started
Learn C++ :
- If you have already gone through ESC112( any Coding Course in C) then you may follow this article for a smooth transition : Moving from C to C++
- If you have no prior coding experience , you can follow :
- For youtube fans :(They also have a guide to setup)
- Bro Code : [first 5 hours]
- OR
- Free Code Camp : [first 3 hours]
- If you prefer to read, then :
- USACO : PAPS(book Chapter 2)
- OR
- Learn C++ (Just the intro and functions parts)
Setting Up Environment :
We prefer VS CODE because of obvious reasons, still feel free to use any other usable Code Editor like : sublime text , codeblocks , etc.
➡️Basic Problem Solving
- Your first problem on Codeforces
- Starting with a less interactive platform like CodeForces can be difficult, but don't worry we got your back :
- start by registering yourself on https://codeforces.com/
- Here's Everyone's First Problem, have a look
- Head to your local IDE
- When you pass the sample inputs locally, click on Submit.
- You can paste your entire code to the Source Code section (OR upload your solution.cpp file) and press Submit.
- Link : Problem 1 ; here you can only submit the solution as a file. Head to your local IDE and write up a 'solution.cpp'
- Run locally and check the code
- Press on the Submit tab and Upload the code file. The results of Online Judge will be displayed in some time.
- Make sure to use long long int ;)
Fast I/O (optional for now):
What it is :
Try this problem with Fast I/O :
- USACO has problems revolving around Farmer John's Farm and (mostly) His Cows.
- Make a new account here. Whenever you go to a problem, you can press the 'Overview' tab to head to the same page for logins.
- You can only submit the solution as a file; apart from that you might be required to get input from a file , output your answer to a file (all that will be processed on server).
- Ex : mixmilk.in for input and mixmilk.out for output. Then you need to add these lines at the start of your code:
- Link : Mixing Milk ; Head to your local IDE and write up a solution.cpp.
- Create mixmilk.in locally in the same folder as your solution.cpp; enter sample input in it (treat .in and .out as .txt files).
- Run locally and check the code.
- Upload the file, Select C++11, Submit. The results of Online Judge will be displayed in some time.
Basic Math Problems
Some suggestions from the Makers :
- We believe that a lot of practice is what shapes you in CP ; apart from the questions found here , it is suggested to practice more problems whenever you feel.
- It is sometimes okay to look up the solution / editorial (for codeforces). Don't fret if you're not able to solve a problem, you'll get it with practice.
- The "Expected time" is the amount of time you will need to give to prepare the theory in a heading before practicing.
- Take your time to understand things and implement them. The expected time is suggestive and varies from person to person, but do not spend too much time on a single topic.
- Consistency is very important in CP. It is highly recommended that you keep practicing it at your own pace daily, rather than doing it all at once. It is a skill that develops over time.
➡️ Time Complexity
Expected time : 40 - 50 minutes
Solve these in O(n) :
➡️ Intro to STL
Expected time : 40 - 60 minutes
OR
Basic Array / Vectors Problems
Basic String Problems
➡️ Sorting
Expected time : 2 - 2.5 hours
More on STL
Expected time : 40 - 60 minutes
Hint
Each Data Structure in STL has its own strengths and weaknesses. Try to think what to use according to the problems.
➡️ Binary Search
Expected time : 40 - 60 minutes
Alternative Soln Link
➡️ Bit Operations
Expected time : 1 - 1.5 hours
➡️Primary Number Theory
Expected time : 1 - 1.5 hours
Binary Exponentiation
Expected time : 20 - 30 minutes
Factorisation [till O(rootN)]
Expected time : 20 - 30 minutes
Gcd
Expected time : 20 - 30 minutes
➡️ Recursion
Expected time : 1.5 - 2 hours
➡️ Complete Search
Expected time : 1.5 - 2 hours
By now, you may have realized that debugging your code efficiently is very important. For a few tips on debugging, you can go through this article / this video.
➡️ Section 0 Additional Practice:
Section 1: Basic Theory
Interactive Problems
Dynamic Programming
Intro to Greedy Algorithms
Divide and Conquer
Range Queries
Two Pointers / Sliding Windows
Number Theory
SECTION 1
➡️ Number Theory
Number Sieve
Expected time : 1 - 1.5 hours
Modular Multiplicative Inverse
Expected time : 20 - 30 minutes
Additional Practice :