Algorithms for Competitive ProgrammingThe goal of this project is to translate the wonderful resource http://e-maxx.ru/algo which provides descriptions of many algorithms and data structures especially popular in field of competitive programming. Moreover we want to improve the collected knowledge by extending the articles and adding new articles to the collection.https://cp-algorithms.com/https://github.com/cp-algorithms/cp-algorithmsen-NoneSun, 24 Sep 2023 19:05:06 -0000Sun, 24 Sep 2023 19:05:06 -00001440MkDocs RSS plugin - v1.8.0Dynamic Programming on Broken Profile. Problem "Parquet"<h1>Dynamic Programming on Broken Profile. Problem "Parquet"</h1><p>Common problems solved using DP on broken profile include:</p><ul><li>finding number of ways to fully fil...</li></ul>https://cp-algorithms.com/dynamic_programming/profile-dynamics.html Sun, 24 Sep 2023 19:03:27 +0000Dijkstra - finding shortest paths from given vertex<h1>Dijkstra Algorithm</h1><p>You are given a directed or undirected weighted graph with $n$ vertices and $m$ edges. The weights of all edges are non-negative. You a...</p>https://cp-algorithms.com/graph/dijkstra.html Sun, 24 Sep 2023 19:03:27 +0000Suffix Array<h1>Suffix Array</h1><h2>Definition</h2><p>Let $s$ be a string of length $n$. The $i$-th suffix of $s$ is the substring $s[i \ldots n - 1]$.</p><p>A <strong>suffix array</strong> will con...</p>https://cp-algorithms.com/string/suffix-array.html Sun, 24 Sep 2023 19:03:27 +0000Preview<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script><script type="text/javascript"> $(document).ready(function(){ ...https://cp-algorithms.com/preview.html Sun, 24 Sep 2023 18:27:05 +0000Binary Search<h1>Binary search</h1><p><strong>Binary search</strong> is a method that allows for quicker search of something by splitting the search interval into two. Its most common applica...</p>https://cp-algorithms.com/num_methods/binary_search.html Sun, 24 Sep 2023 18:22:52 +0000Sqrt Tree<h1>Sqrt Tree</h1><p>Given an array $a$ that contains $n$ elements and the operation $\circ$ that satisfies associative property: $(x \circ y) \circ z = x \circ (y ...</p>https://cp-algorithms.com/data_structures/sqrt-tree.html Sun, 24 Sep 2023 17:42:01 +0000Josephus problem<h1>Josephus Problem</h1><h2>Statement</h2><p>We are given the natural numbers $n$ and $k$.All natural numbers from $1$ to $n$ are written in a circle. First, count th...</p>https://cp-algorithms.com/others/josephus_problem.html Sun, 24 Sep 2023 17:42:01 +0000Manacher's Algorithm - Finding all sub-palindromes in O(N)<h1>Manacher's Algorithm - Finding all sub-palindromes in $O(N)$</h1><h2>Statement</h2><p>Given string $s$ with length $n$. Find all the pairs $(i, j)$ such that substri...</p>https://cp-algorithms.com/string/manacher.html Sun, 24 Sep 2023 17:42:01 +0000Lowest Common Ancestor - Binary Lifting<h1>Lowest Common Ancestor - Binary Lifting</h1><p>Let $G$ be a tree.For every query of the form <code>(u, v)</code> we want to find the lowest common ancestor of the nodes `u...</p>https://cp-algorithms.com/graph/lca_binary_lifting.html Sun, 24 Sep 2023 17:40:02 +00002-SAT<h1>2-SAT</h1><p>SAT (Boolean satisfiability problem) is the problem of assigning Boolean values to variables to satisfy a given Boolean formula.The Boolean formul...</p>https://cp-algorithms.com/graph/2SAT.html Sat, 23 Sep 2023 16:48:18 +0000Point location in O(log N)<h1>Point location in $O(log n)$</h1><p>Consider the following problem: you are given a [planar subdivision](https://en.wikipedia.org/wiki/Planar_straight-line_graph...</p>https://cp-algorithms.com/geometry/point-location.html Fri, 22 Sep 2023 11:17:11 +0000Segment Tree<h1>Segment Tree</h1><p>A Segment Tree is a data structure that stores information about array intervals as a tree. This allows answering range queries over an array...</p>https://cp-algorithms.com/data_structures/segment_tree.html Sun, 17 Sep 2023 16:58:19 +0000Maximum flow - Ford-Fulkerson and Edmonds-Karp<h1>Maximum flow - Ford-Fulkerson and Edmonds-Karp</h1><p>The Edmonds-Karp algorithm is an implementation of the Ford-Fulkerson method for computing a maximal flow i...</p>https://cp-algorithms.com/graph/edmonds_karp.html Sun, 17 Sep 2023 16:48:17 +0000Finding Bridges Online<h1>Finding Bridges Online</h1><p>We are given an undirected graph.A bridge is an edge whose removal makes the graph disconnected (or, more precisely, increases the...</p>https://cp-algorithms.com/graph/bridge-searching-online.html Sat, 16 Sep 2023 14:08:10 +0000Tortoise and Hare Algorithm (Linked List cycle detection)<h1>Floyd's Linked List Cycle Finding Algorithm</h1><p>Given a linked list where the starting point of that linked list is denoted by <strong>head</strong>, and there may or may ...</p>https://cp-algorithms.com/others/tortoise_and_hare.html Wed, 13 Sep 2023 08:41:02 +0000Binary Exponentiation<h1>Binary Exponentiation</h1><p>Binary exponentiation (also known as exponentiation by squaring) is a trick which allows to calculate $a^n$ using only $O(\log n)$ m...</p>https://cp-algorithms.com/algebra/binary-exp.html Tue, 12 Sep 2023 15:50:59 +0000Navigation<ul><li>Home<ul><li><a href="index.md">Main Page</a></li><li><a href="navigation.md">Navigation</a></li><li><a href="tags.md">Tag index</a></li><li><a href="contrib.md">How to Contribute</a></li><li>[Code of conduct]...</li></ul></li></ul>https://cp-algorithms.com/navigation.html Sun, 10 Sep 2023 08:20:59 +0000Integer factorization<h1>Integer factorization</h1><p>In this article we list several algorithms for factorizing integers, each of them can be both fast and also slow (some slower than o...</p>https://cp-algorithms.com/algebra/factorization.html Sun, 10 Sep 2023 08:20:59 +0000Fenwick Tree<h1>Fenwick Tree</h1><p>Let, $f$ be some group operation (binary associative function over a set with identity element and inverse elements) and $A$ be an array of i...</p>https://cp-algorithms.com/data_structures/fenwick.html Fri, 01 Sep 2023 05:53:19 +0000Suffix Automaton<h1>Suffix Automaton</h1><p>A <strong>suffix automaton</strong> is a powerful data structure that allows solving many string-related problems. </p><p>For example, you can search for a...</p>https://cp-algorithms.com/string/suffix-automaton.html Sun, 27 Aug 2023 21:34:43 +0000