Skip to content

pranavsindura/cp-resources

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Competitive Programming Resources

The idea is to have a list of hand-picked resources, that can help everyone get into Competitive Programming. Hopefully, will be updated frequently. Suggestions are welcome.

Remember that it is not necessary to go through everything. Pick whatever works for you.

These are the things I know and/or have heard about.

C++

Reading / Watching

Environment

Practice

References

Websites / Online Judges

You can register yourself on these Websites/OJs. They have a huge list of problems to solve and blogs to learn from. Some of them will be referenced later on. They also organise contests, where we can compete with others.

Algorithms and Data Structures

Important part of CP is to learn algorithms and techniques, practice problems, and to develop algorithmic and constructive thinking.

The best way to progress is to picking an OJ, stick with it and solve problems related to the topics you learn.

Participate in contests and learn from other people.

How to start? Pick first few topics from each heading and learn about them one by one.

Reading / Watching

References

Please use the above Links for reading about the topics mentioned below. The books are extremely helpful for implementation ideas.

Tree / Graph

Topics

  • Graph Theory

    • Tree/Graph
    • Edges/Nodes
    • Edge Classification
    • Directed/Undirected
    • Degrees
    • Colorings
    • Weights
    • Cycles
    • Connected Components/Strongly Connected Components
    • Topological Order
    • Bipartiteness
    • Spanning Trees
    • Tree Diameter
    • Tree Isomorphism and Canonical Forms
    • Tree Centers
    • Planar Graphs
      • Euler's Characterstic
    • Flows
      • Max-Flow and Min-Cut
      • Maximum edge disjoint paths
      • Maximum independent path / Maximum vertex disjoint path
      • Maximum Bipartite Matching on Bipartite graphs
      • Minimum edges to be removed to disconnect a graph
      • Minimum nodes to be removed to disconnect a graph
      • Minimum Path coverage in DAG / Vertex Disjoint Path Cover in DAG
      • Minimum Edge cover
      • Maximum Independent Set
  • Algorithms

    • Graph Representation
    • BFS/DFS
    • BFS/DFS on Grid
    • Topological Sorting
    • Minimum Spanning Tree
      • Kruskal
      • Prims
      • Second MST
    • Shortest Paths
      • Single Source Shortest Path
        • Dijkstra
        • 0/1 BFS
        • Bellman Ford
        • SPFA
      • All Pair Shortest Path
        • Floyd Warshall
          • Shortest Paths
          • Transitive Closure
          • Path building
          • SCC
          • Counting Paths
          • Checking Cycles
          • Graph Diameter
        • N-Dijkstra
      • Shortest paths with exactly / atmost K edges (min, + multiplication)
      • K-th Shortest Paths
        • with Dijkstra bounded by visiting each node atmost K times
        • Cyclic Graphs
          • Eppstein's Algorithm
        • Non Cyclic Graphs
          • Yen's Algorithm
    • Flows
      • Max-Flow and Min-Cut
        • Blog 1
        • Blog 2
        • Ford-Fulkerson Algorithm
        • Edmonds-Karp Algorithm
        • Vertex Splitting
        • Multi Source / Multi Sink
      • Finding the Min-Cut Edges
    • Travelling Salesman Problem
  • Data Structures

    • Disjoint Set Union Find (DSU)
    • Segment Tree
    • Fenwick Tree (BIT)
    • Trie
    • Treap

Related Contests

DP

Most of the time it is easier to write Recursion + Memo. It can be converted to iterative later as it supports more optimizations.

Topics

  • Theory
    • Overlapping subproblems
    • Optimal substructure
  • Types
    • Subsets / Subsequences
    • Ranges
      • Consecutive (Subarrays / Substrings)
      • Nested
      • General
    • Minimization / Maximization
    • Counting
    • Tracing / Building Output
    • on Trees
    • Probability
    • Bitmasks
    • Games
  • Optimizations
  • Tricks
    • Maintain difference of 2 params instead of actual params
    • Cyclic Dependencies + Recursion - Set value of DP to base case before recursing

Related Contests

Mathematics

Eveything upto Class XII Maths and more. Discrete Mathematics forms an important part of CP related maths.

Topics

  • Algebra
    • Number System
    • Base conversion
    • Adders
      • Half Adder
      • Full Adder
  • Number Theory
    • Euler's GCD algorithm (and Extended)
    • Binary Exponentiation/Multiplication
    • Factorisation / Divisors
    • Sieve (Linear)
    • Powers of Number in n!
    • Goldbach's Conjecture
    • Linear Diophantine Equation
    • Euler's Characterstic
    • Mobius Inversion
  • Important Sequences/Series/Numbers/Functions
    • Binomial Theorem/Pascal's Triangle
    • Stirling Numbers First and Second kind
    • Bell Number
    • Catalan Numbers
    • Bertrand's Ballot Theorem
      • Reflection Principle
    • Euler's Totient Function
    • Mobius Function
  • Modular Arithmetic
  • Combinatorics
    • Factorial
    • nCr
      • 2D Table
      • Factorial + Multiplicative Inverse
    • Inclusion Exclusion Principle
    • Stars and Bars
    • Pigeon-hole Principle
    • Counting distinct subtrees of a tree
  • Geometry
    • Trigonometry
    • Vector Algebra
    • Points
      • Euclidean Distance
      • Manhattan Distance
      • Centroid
      • Fermat Point / Geometric Median [UVA 10228]
    • Lines
      • Equation of Line
      • Distance from Point to Line
      • Line-Line intersection
        • Parametric Form
        • Cartesian Form
    • Line Segments
      • Check Intersection (Cross products)
      • Find Intersection (Cramer's Rule)
      • Check if point lies on line segment
    • Circles
      • Equation of Circle
      • Construct Circle with 3 points
      • Line and Circle Intersection
      • Circle Circle Intersection
        • Check Intersection (Radii and distances from center)
        • Find Intersection (Cosine Rule and Dot product)
      • Minimal Enclosing Circle
      • Tangent to a circle from a given point
    • Polygon
      • Properties
        • Simple/Non Simple
        • Convex/Concave
      • Square
        • Check if 4 points form a square
      • Polygon Area
      • Point inside polygon
        • Winding Number Rule
      • Polygon Centroid
        • Polygon Decomposition (into Triangles)
      • Polygon Cut by line
      • Polygon inside polygon
        • Repeatedly cut one polygon by other polygon
      • Shortest Distance between 2 polygons
    • Closest Pair of Points problem
  • Probability / Statistics
    • Mean, Median, Mode
    • Bayes' Theorem
    • Random Variable
    • Expected Value
    • Linearity of Expectation
  • Matrices
    • Matrix operations
    • Determinant
    • Cofactors
    • Cramer's Rule
    • Solving System of Linear equations
    • Matrix exponentiation
    • Hadamard Matrix
  • Searching
  • Game Theory
    • Optimal Move
    • Winning/Losing State
    • Dependence on Initial/Final State

References

  • Mathematical Circles: (Russian Experience) - Dmitrii Vladimirovich Fomin and Sergei Aleksandrovich Genkin

Strings

Topics

  • Theory
    • Substrings
    • Subsequences
    • Palindromes
  • Algorithms
    • Prefix/Failure Function
    • String Matching
      • KMP
      • Rabin-Karp
    • String Hashing
  • Data Structures
    • Trie

Random Tasks / Tricks

  • Difference array, range updates in O(1)
  • Largest Rectangle in Histogram
  • Median of running data with 2 Heaps
  • Powers of Number in n!
  • Largest Area in a room from where we can see all walls
  • Calculations involving multiplication/division (like Factorial) can be written in Prime exponent form
  • Building Prefix array instead of actual array in case of XOR problems

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages