Skip to content

Commit b0c987e

Browse files
Oleksandr Kulkovadamant-pwn
Oleksandr Kulkov
authored andcommitted
Enable macros
1 parent 7e60050 commit b0c987e

13 files changed

+271
-289
lines changed

.github/workflows/deploy-prod.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
python-version: '3.8'
1919
- name: Install mkdocs-material
2020
run: |
21-
pip install mkdocs-material
21+
pip install mkdocs-material mkdocs-macros-plugin
2222
- name: Build pages
2323
run: |
2424
mkdocs build --strict

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
python-version: '3.8'
1515
- name: Install mkdocs-material
1616
run: |
17-
pip install mkdocs-material
17+
pip install mkdocs-material mkdocs-macros-plugin
1818
- name: Set up C++
1919
run: |
2020
sudo apt install -y --no-install-recommends build-essential

README.md

-33
This file was deleted.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/index_body

mkdocs.yml

+8
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,21 @@ markdown_extensions:
4646
- pymdownx.emoji:
4747
emoji_index: !!python/name:materialx.emoji.twemoji
4848
emoji_generator: !!python/name:materialx.emoji.to_svg
49+
- meta
50+
51+
plugins:
52+
- search
53+
- macros
54+
#- git-authors
55+
4956
extra:
5057
analytics:
5158
provider: google
5259
property: UA-85220282-1
5360
nav:
5461
- 'Home':
5562
- 'index.md'
63+
- 'navigation.md'
5664
- 'contrib.md'
5765
- 'preview.md'
5866
- 'Algebra':

src/algebra/module-inverse.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ From these results, we can easily find the modular inverse using the [binary exp
7070

7171
Even though this method is easier to understand than the method described in previous paragraph, in the case when $m$ is not a prime number, we need to calculate Euler phi function, which involves factorization of $m$, which might be very hard. If the prime factorization of $m$ is known, then the complexity of this method is $O(\log m)$.
7272

73-
## Finding the modular inverse for every number modulo $m$ {#mod-inv-all-num data-toc-label="Finding the modular inverse for every number modulo m"}
73+
## Finding the modular inverse for every number modulo $m$ { #mod-inv-all-num data-toc-label="Finding the modular inverse for every number modulo m"}
7474

7575
The problem is the following:
7676
we want to compute the modular inverse for every number in the range $[1, m-1]$.

src/algebra/phi-function.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void phi_1_to_n(int n) {
8989
```
9090

9191

92-
## Divisor sum property {#divsum}
92+
## Divisor sum property { #divsum}
9393

9494
This interesting property was established by Gauss:
9595

src/combinatorics/binomial-coefficients.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ long long binomial_coefficient(int n, int k) {
159159
}
160160
```
161161

162-
### Binomial coefficient modulo prime power {#mod-prime-pow}
162+
### Binomial coefficient modulo prime power { #mod-prime-pow}
163163

164164
Here we want to compute the binomial coefficient modulo some prime power, i.e. $m = p^b$ for some prime $p$.
165165
If $p > \max(k, n-k)$, then we can use the same method as described in the previous section.

src/data_structures/disjoint_set_union.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ bool is_bipartite(int v) {
422422
}
423423
```
424424

425-
### Offline RMQ (range minimum query) in $O(\alpha(n))$ on average / Arpa's trick {#arpa data-toc-label="Offline RMQ / Arpa's trick"}
425+
### Offline RMQ (range minimum query) in $O(\alpha(n))$ on average / Arpa's trick { #arpa data-toc-label="Offline RMQ / Arpa's trick"}
426426

427427
We are given an array `a[]` and we have to compute some minima in given segments of the array.
428428

src/data_structures/segment_tree.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ The green vertices are the vertices that we visit and update.
148148

149149
!["Sum Segment Tree Update"](sum-segment-tree-update.png)
150150

151-
### Implementation ### {#implementation}
151+
### Implementation ### { #implementation}
152152

153153
The main consideration is how to store the Segment Tree.
154154
Of course we can define a $\text{Vertex}$ struct and create objects, that store the boundaries of the segment, its sum and additionally also pointers to its child vertices.
@@ -325,7 +325,7 @@ This interesting variation of the Segment Tree can be solved in exactly the same
325325
it is enough to store the GCD / LCM of the corresponding vertex in each vertex of the tree.
326326
Combining two vertices can be done by computing the GCD / LCM of both vertices.
327327

328-
#### Counting the number of zeros, searching for the $k$-th zero {#counting-zero-search-kth data-toc-label="Counting the number of zeros, searching for the k-th zero"}
328+
#### Counting the number of zeros, searching for the $k$-th zero { #counting-zero-search-kth data-toc-label="Counting the number of zeros, searching for the k-th zero"}
329329

330330
In this problem we want to find the number of zeros in a given range, and additionally find the index of the $k$-th zero using a second function.
331331

src/graph/edmonds_karp.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ int maxflow(int s, int t) {
176176
}
177177
```
178178
179-
## Integral flow theorem ## {#integral-theorem}
179+
## Integral flow theorem ## { #integral-theorem}
180180
181181
The theorem simply says, that if every capacity in the network is an integer, then the flow in each edge will be an integer in the maximal flow.
182182

src/index.md

+1-247
Original file line numberDiff line numberDiff line change
@@ -1,251 +1,5 @@
11
---
22
title: Main Page
33
---
4-
# Algorithms for Competitive Programming
54

6-
*The goal of this project is to translate the wonderful resource
7-
[http://e-maxx.ru/algo](http://e-maxx.ru/algo) which provides descriptions of many algorithms
8-
and data structures especially popular in field of competitive programming.
9-
Moreover we want to improve the collected knowledge by extending the articles
10-
and adding new articles to the collection.*
11-
12-
## Changelog
13-
14-
15-
- June 5, 2022: Enabled content tabs and sidebar navigation. The navigation structure should be adjusted in [mkdocs.yml](https://github.com/e-maxx-eng/e-maxx-eng/blob/master/mkdocs.yml) whenever a new article is created or an old one is moved.
16-
- January 16, 2022: Switched to the [MkDocs](https://www.mkdocs.org/) site generator with the [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) theme, which give the website a more modern look, brings a couple of new features (dark mode, better search, ...), makes the website more stable (in terms of rendering math formulas), and makes it easier to contribute.
17-
18-
## New articles
19-
20-
- (12 May 2022) [Factoring Exponentiation](algebra/factoring-exp.md)
21-
- (7 May 2022) [Knuth's Optimization](dynamic_programming/knuth-optimization.md)
22-
- (31 March 2022) [Continued fractions](algebra/continued-fractions.md)
23-
24-
Full list of updates: [Commit History](https://github.com/e-maxx-eng/e-maxx-eng/commits/master)
25-
26-
## Contributing
27-
28-
- [Information for contributors](contrib.md)
29-
- [Test-Your-Page form](preview.md)
30-
31-
---
32-
33-
## Articles
34-
35-
### Algebra
36-
37-
- **Fundamentals**
38-
- [Binary Exponentiation](algebra/binary-exp.md)
39-
- [Factoring Exponentiation](algebra/factoring-exp.md)
40-
- [Euclidean algorithm for computing the greatest common divisor](algebra/euclid-algorithm.md)
41-
- [Extended Euclidean Algorithm](algebra/extended-euclid-algorithm.md)
42-
- [Linear Diophantine Equations](algebra/linear-diophantine-equation.md)
43-
- [Fibonacci Numbers](algebra/fibonacci-numbers.md)
44-
- **Prime numbers**
45-
- [Sieve of Eratosthenes](algebra/sieve-of-eratosthenes.md)
46-
- [Linear Sieve](algebra/prime-sieve-linear.md)
47-
- [Primality tests](algebra/primality_tests.md)
48-
- [Integer factorization](algebra/factorization.md)
49-
- **Number-theoretic functions**
50-
- [Euler's totient function](algebra/phi-function.md)
51-
- [Number of divisors / sum of divisors](algebra/divisors.md)
52-
- **Modular arithmetic**
53-
- [Modular Inverse](algebra/module-inverse.md)
54-
- [Linear Congruence Equation](algebra/linear_congruence_equation.md)
55-
- [Chinese Remainder Theorem](algebra/chinese-remainder-theorem.md)
56-
- [Factorial modulo $p$](algebra/factorial-modulo.md)
57-
- [Discrete Log](algebra/discrete-log.md)
58-
- [Primitive Root](algebra/primitive-root.md)
59-
- [Discrete Root](algebra/discrete-root.md)
60-
- [Montgomery Multiplication](algebra/montgomery_multiplication.md)
61-
- **Number systems**
62-
- [Balanced Ternary](algebra/balanced-ternary.md)
63-
- [Gray code](algebra/gray-code.md)
64-
- **Miscellaneous**
65-
- [Enumerating submasks of a bitmask](algebra/all-submasks.md)
66-
- [Arbitrary-Precision Arithmetic](algebra/big-integer.md)
67-
- [Fast Fourier transform](algebra/fft.md)
68-
- [Operations on polynomials and series](algebra/polynomial.md)
69-
- [Continued fractions](algebra/continued-fractions.md)
70-
71-
### Data Structures
72-
73-
- **Fundamentals**
74-
- [Minimum Stack / Minimum Queue](data_structures/stack_queue_modification.md)
75-
- [Sparse Table](data_structures/sparse-table.md)
76-
- **Trees**
77-
- [Disjoint Set Union](data_structures/disjoint_set_union.md)
78-
- [Fenwick Tree](data_structures/fenwick.md)
79-
- [Sqrt Decomposition](data_structures/sqrt_decomposition.md)
80-
- [Segment Tree](data_structures/segment_tree.md)
81-
- [Treap](data_structures/treap.md)
82-
- [Sqrt Tree](data_structures/sqrt-tree.md)
83-
- [Randomized Heap](data_structures/randomized_heap.md)
84-
- **Advanced**
85-
- [Deleting from a data structure in O(T(n)log n)](data_structures/deleting_in_log_n.md)
86-
87-
### Dynamic Programming
88-
89-
- **DP optimizations**
90-
- [Divide and Conquer DP](dynamic_programming/divide-and-conquer-dp.md)
91-
- [Knuth's Optimization](dynamic_programming/knuth-optimization.md)
92-
- **Tasks**
93-
- [Dynamic Programming on Broken Profile. Problem "Parquet"](dynamic_programming/profile-dynamics.md)
94-
- [Finding the largest zero submatrix](dynamic_programming/zero_matrix.md)
95-
96-
### String Processing
97-
98-
- **Fundamentals**
99-
- [String Hashing](string/string-hashing.md)
100-
- [Rabin-Karp for String Matching](string/rabin-karp.md)
101-
- [Prefix function - Knuth-Morris-Pratt](string/prefix-function.md)
102-
- [Z-function](string/z-function.md)
103-
- [Suffix Array](string/suffix-array.md)
104-
- [Aho-Corasick algorithm](string/aho_corasick.md)
105-
- **Advanced**
106-
- [Suffix Tree](string/suffix-tree-ukkonen.md)
107-
- [Suffix Automaton](string/suffix-automaton.md)
108-
- [Lyndon factorization](string/lyndon_factorization.md)
109-
- **Tasks**
110-
- [Expression parsing](string/expression_parsing.md)
111-
- [Manacher's Algorithm - Finding all sub-palindromes in O(N)](string/manacher.md)
112-
- [Finding repetitions](string/main_lorentz.md)
113-
114-
### Linear Algebra
115-
116-
- **Matrices**
117-
- [Gauss & System of Linear Equations](linear_algebra/linear-system-gauss.md)
118-
- [Gauss & Determinant](linear_algebra/determinant-gauss.md)
119-
- [Kraut & Determinant](linear_algebra/determinant-kraut.md)
120-
- [Rank of a matrix](linear_algebra/rank-matrix.md)
121-
122-
### Combinatorics
123-
124-
- **Fundamentals**
125-
- [Finding Power of Factorial Divisor](algebra/factorial-divisors.md)
126-
- [Binomial Coefficients](combinatorics/binomial-coefficients.md)
127-
- [Catalan Numbers](combinatorics/catalan-numbers.md)
128-
- **Techniques**
129-
- [The Inclusion-Exclusion Principle](combinatorics/inclusion-exclusion.md)
130-
- [Burnside's lemma / Pólya enumeration theorem](combinatorics/burnside.md)
131-
- [Stars and bars](combinatorics/stars_and_bars.md)
132-
- [Generating all $K$-combinations](combinatorics/generating_combinations.md)
133-
- **Tasks**
134-
- [Placing Bishops on a Chessboard](combinatorics/bishops-on-chessboard.md)
135-
- [Balanced bracket sequences](combinatorics/bracket_sequences.md)
136-
- [Counting labeled graphs](combinatorics/counting_labeled_graphs.md)
137-
138-
### Numerical Methods
139-
140-
- **Search**
141-
- [Ternary Search](num_methods/ternary_search.md)
142-
- [Newton's method for finding roots](num_methods/roots_newton.md)
143-
- **Integration**
144-
- [Integration by Simpson's formula](num_methods/simpson-integration.md)
145-
146-
### Geometry
147-
148-
- **Elementary operations**
149-
- [Basic Geometry](geometry/basic-geometry.md)
150-
- [Finding the equation of a line for a segment](geometry/segment-to-line.md)
151-
- [Intersection Point of Lines](geometry/lines-intersection.md)
152-
- [Check if two segments intersect](geometry/check-segments-intersection.md)
153-
- [Intersection of Segments](geometry/segments-intersection.md)
154-
- [Circle-Line Intersection](geometry/circle-line-intersection.md)
155-
- [Circle-Circle Intersection](geometry/circle-circle-intersection.md)
156-
- [Common tangents to two circles](geometry/tangents-to-two-circles.md)
157-
- [Length of the union of segments](geometry/length-of-segments-union.md)
158-
- **Polygons**
159-
- [Oriented area of a triangle](geometry/oriented-triangle-area.md)
160-
- [Area of simple polygon](geometry/area-of-simple-polygon.md)
161-
- [Check if points belong to the convex polygon in O(log N)](geometry/point-in-convex-polygon.md)
162-
- [Minkowski sum of convex polygons](geometry/minkowski.md)
163-
- [Pick's Theorem - area of lattice polygons](geometry/picks-theorem.md)
164-
- [Lattice points of non-lattice polygon](geometry/lattice-points.md)
165-
- **Convex hull**
166-
- [Convex hull construction](geometry/convex-hull.md)
167-
- [Convex hull trick and Li Chao tree](geometry/convex_hull_trick.md)
168-
- **Sweep-line**
169-
- [Search for a pair of intersecting segments](geometry/intersecting_segments.md)
170-
- [Point location in O(log N)](geometry/point-location.md)
171-
- **Miscellaneous**
172-
- [Finding the nearest pair of points](geometry/nearest_points.md)
173-
- [Delaunay triangulation and Voronoi diagram](geometry/delaunay.md)
174-
- [Vertical decomposition](geometry/vertical_decomposition.md)
175-
- [Half-plane intersection - S&I Algorithm in O(Nlog N)](geometry/halfplane-intersection.md)
176-
177-
### Graphs
178-
179-
- **Graph traversal**
180-
- [Breadth First Search](graph/breadth-first-search.md)
181-
- [Depth First Search](graph/depth-first-search.md)
182-
- **Connected components, bridges, articulations points**
183-
- [Finding Connected Components](graph/search-for-connected-components.md)
184-
- [Finding Bridges in O(N+M)](graph/bridge-searching.md)
185-
- [Finding Bridges Online](graph/bridge-searching-online.md)
186-
- [Finding Articulation Points in O(N+M)](graph/cutpoints.md)
187-
- [Strongly Connected Components and Condensation Graph](graph/strongly-connected-components.md)
188-
- [Strong Orientation](graph/strong-orientation.md)
189-
- **Single-source shortest paths**
190-
- [Dijkstra - finding shortest paths from given vertex](graph/dijkstra.md)
191-
- [Dijkstra on sparse graphs](graph/dijkstra_sparse.md)
192-
- [Bellman-Ford - finding shortest paths with negative weights](graph/bellman_ford.md)
193-
- [0-1 BFS](graph/01_bfs.md)
194-
- [D´Esopo-Pape algorithm](graph/desopo_pape.md)
195-
- **All-pairs shortest paths**
196-
- [Floyd-Warshall - finding all shortest paths](graph/all-pair-shortest-path-floyd-warshall.md)
197-
- [Number of paths of fixed length / Shortest paths of fixed length](graph/fixed_length_paths.md)
198-
- **Spanning trees**
199-
- [Minimum Spanning Tree - Prim's Algorithm](graph/mst_prim.md)
200-
- [Minimum Spanning Tree - Kruskal](graph/mst_kruskal.md)
201-
- [Minimum Spanning Tree - Kruskal with Disjoint Set Union](graph/mst_kruskal_with_dsu.md)
202-
- [Second best Minimum Spanning Tree - Using Kruskal and Lowest Common Ancestor](graph/second_best_mst.md)
203-
- [Kirchhoff Theorem](graph/kirchhoff-theorem.md)
204-
- [Prüfer code](graph/pruefer_code.md)
205-
- **Cycles**
206-
- [Checking a graph for acyclicity and finding a cycle in O(M)](graph/finding-cycle.md)
207-
- [Finding a Negative Cycle in the Graph](graph/finding-negative-cycle-in-graph.md)
208-
- [Eulerian Path](graph/euler_path.md)
209-
- **Lowest common ancestor**
210-
- [Lowest Common Ancestor](graph/lca.md)
211-
- [Lowest Common Ancestor - Binary Lifting](graph/lca_binary_lifting.md)
212-
- [Lowest Common Ancestor - Farach-Colton and Bender algorithm](graph/lca_farachcoltonbender.md)
213-
- [Solve RMQ by finding LCA](graph/rmq_linear.md)
214-
- [Lowest Common Ancestor - Tarjan's off-line algorithm](graph/lca_tarjan.md)
215-
- **Flows and related problems**
216-
- [Maximum flow - Ford-Fulkerson and Edmonds-Karp](graph/edmonds_karp.md)
217-
- [Maximum flow - Push-relabel algorithm](graph/push-relabel.md)
218-
- [Maximum flow - Push-relabel algorithm improved](graph/push-relabel-faster.md)
219-
- [Maximum flow - Dinic's algorithm](graph/dinic.md)
220-
- [Maximum flow - MPM algorithm](graph/mpm.md)
221-
- [Flows with demands](graph/flow_with_demands.md)
222-
- [Minimum-cost flow](graph/min_cost_flow.md)
223-
- [Assignment problem. Solution using min-cost-flow in O (N^5)](graph/Assignment-problem-min-flow.md)
224-
- **Matchings and related problems**
225-
- [Bipartite Graph Check](graph/bipartite-check.md)
226-
- [Kuhn's Algorithm - Maximum Bipartite Matching](graph/kuhn_maximum_bipartite_matching.md)
227-
- **Miscellaneous**
228-
- [Topological Sorting](graph/topological-sort.md)
229-
- [Edge connectivity / Vertex connectivity](graph/edge_vertex_connectivity.md)
230-
- [Tree painting](graph/tree_painting.md)
231-
- [2-SAT](graph/2SAT.md)
232-
- [Heavy-light decomposition](graph/hld.md)
233-
234-
### Miscellaneous
235-
236-
- **Sequences**
237-
- [RMQ task (Range Minimum Query - the smallest element in an interval)](sequences/rmq.md)
238-
- [Longest increasing subsequence](sequences/longest_increasing_subsequence.md)
239-
- [Search the subsegment with the maximum/minimum sum](others/maximum_average_segment.md)
240-
- [K-th order statistic in O(N)](sequences/k-th.md)
241-
- **Game Theory**
242-
- [Games on arbitrary graphs](game_theory/games_on_graphs.md)
243-
- [Sprague-Grundy theorem. Nim](game_theory/sprague-grundy-nim.md)
244-
- **Schedules**
245-
- [Scheduling jobs on one machine](schedules/schedule_one_machine.md)
246-
- [Scheduling jobs on two machines](schedules/schedule_two_machines.md)
247-
- [Optimal schedule of jobs given their deadlines and durations](schedules/schedule-with-completion-duration.md)
248-
- **Miscellaneous**
249-
- [Josephus problem](others/josephus_problem.md)
250-
- [15 Puzzle Game: Existence Of The Solution](others/15-puzzle.md)
251-
- [The Stern-Brocot Tree and Farey Sequences](others/stern_brocot_tree_farey_sequences.md)
5+
{% include 'index_body' %}

0 commit comments

Comments
 (0)