Skip to content

Commit e3fe98e

Browse files
authored
Merge branch 'main' into master
2 parents 5f18393 + f1570ff commit e3fe98e

File tree

9 files changed

+375
-369
lines changed

9 files changed

+375
-369
lines changed

src/combinatorics/burnside.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,4 @@ int solve(int n, int m) {
280280
* [SPOJ - Sorting Machine](https://www.spoj.com/problems/SRTMACH/)
281281
* [Project Euler - Pizza Toppings](https://projecteuler.net/problem=281)
282282
* [ICPC 2011 SERCP - Alphabet Soup](https://basecamp.eolymp.com/tr/problems/3064)
283+
* [GCPC 2017 - Buildings](https://basecamp.eolymp.com/en/problems/11615)

src/dynamic_programming/intro-to-dp.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ One of the tricks to getting better at dynamic programming is to study some of t
132132
## Classic Dynamic Programming Problems
133133
| Name | Description/Example |
134134
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
135-
| 0-1 Knapsack | Given $W$, $N$, and $N$ items with weights $w_i$ and values $v_i$, what is the maximum $\sum_{i=1}^{k} v_i$ for each subset of items of size $k$ ($1 \le k \le N$) while ensuring $\sum_{i=1}^{k} w_i \le W$? |
135+
| [0-1 Knapsack](../dynamic_programming/knapsack.md) | Given $W$, $N$, and $N$ items with weights $w_i$ and values $v_i$, what is the maximum $\sum_{i=1}^{k} v_i$ for each subset of items of size $k$ ($1 \le k \le N$) while ensuring $\sum_{i=1}^{k} w_i \le W$? |
136136
| Subset Sum | Given $N$ integers and $T$, determine whether there exists a subset of the given set whose elements sum up to the $T$. |
137-
| Longest Increasing Subsequence (LIS) | You are given an array containing $N$ integers. Your task is to determine the LIS in the array, i.e., a subsequence where every element is larger than the previous one. |
137+
| [Longest Increasing Subsequence (LIS)](../dynamic_programming/longest_increasing_subsequence.md) | You are given an array containing $N$ integers. Your task is to determine the LIS in the array, i.e., a subsequence where every element is larger than the previous one. |
138138
| Counting Paths in a 2D Array | Given $N$ and $M$, count all possible distinct paths from $(1,1)$ to $(N, M)$, where each step is either from $(i,j)$ to $(i+1,j)$ or $(i,j+1)$. |
139139
| Longest Common Subsequence | You are given strings $s$ and $t$. Find the length of the longest string that is a subsequence of both $s$ and $t$. |
140140
| Longest Path in a Directed Acyclic Graph (DAG) | Finding the longest path in Directed Acyclic Graph (DAG). |
@@ -143,7 +143,7 @@ One of the tricks to getting better at dynamic programming is to study some of t
143143
| Edit Distance | The edit distance between two strings is the minimum number of operations required to transform one string into the other. Operations are ["Add", "Remove", "Replace"] |
144144

145145
## Related Topics
146-
* Bitmask Dynamic Programming
146+
* [Bitmask Dynamic Programming](../dynamic_programming/profile-dynamics.md)
147147
* Digit Dynamic Programming
148148
* Dynamic Programming on Trees
149149

src/dynamic_programming/longest_increasing_subsequence.md

Lines changed: 360 additions & 0 deletions
Large diffs are not rendered by default.

src/geometry/enclosing-circle.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ Consider the following problem:
1313

1414
For each $p_i$, find whether it lies on the circumference of the minimum enclosing circle of $\{p_1,\dots,p_n\}$.
1515

16-
Here, by the minimum enclosing circle (MEC) we mean a circle with minimum possible radius that contains all the $n$ p, inside the circle or on its boundary. This problem has a simple randomized solution that, on first glance, looks like it would run in $O(n^3)$, but actually works in $O(n)$ expected time.
16+
Here, by the minimum enclosing circle (MEC) we mean a circle with minimum possible radius that contains all the $n$ points, inside the circle or on its boundary. This problem has a simple randomized solution that, on first glance, looks like it would run in $O(n^3)$, but actually works in $O(n)$ expected time.
1717

1818
To better understand the reasoning below, we should immediately note that the solution to the problem is unique:
1919

2020
??? question "Why is the MEC unique?"
2121

22-
Consider the following setup: Let $r$ be the radius of the MEC. We draw a circle of radius $r$ around each of the p $p_1,\dots,p_n$. Geometrically, the centers of circles that have radius $r$ and cover all the points $p_1,\dots,p_n$ form the intersection of all $n$ circles.
22+
Consider the following setup: Let $r$ be the radius of the MEC. We draw a circle of radius $r$ around each of the points $p_1,\dots,p_n$. Geometrically, the centers of circles that have radius $r$ and cover all the points $p_1,\dots,p_n$ form the intersection of all $n$ circles.
2323

2424
Now, if the intersection is just a single point, this already proves that it is unique. Otherwise, the intersection is a shape of non-zero area, so we can reduce $r$ by a tiny bit, and still have non-empty intersection, which contradicts the assumption that $r$ was the minimum possible radius of the enclosing circle.
2525

2626
With a similar logic, we can also show the uniqueness of the MEC if we additionally demand that it passes through a given specific point $p_i$ or two points $p_i$ and $p_j$ (it is also unique because its radius uniquely defines it).
2727

28-
Alternatively, we can also assume that there are two MECs, and then notice that their intersection (which contains p $p_1,\dots,p_n$ already) must have a smaller diameter than initial circles, and thus can be covered with a smaller circle.
28+
Alternatively, we can also assume that there are two MECs, and then notice that their intersection (which contains the points $p_1,\dots,p_n$ already) must have a smaller diameter than initial circles, and thus can be covered with a smaller circle.
2929

3030
## Welzl's algorithm
3131

src/geometry/point-in-convex-polygon.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,6 @@ bool pointInConvexPolygon(pt point) {
120120
```
121121

122122
## Problems
123-
[SGU253 Theodore Roosevelt](https://codeforces.com/problemsets/acmsguru/problem/99999/253)
124-
[Codeforces 55E Very simple problem](https://codeforces.com/contest/55/problem/E)
123+
* [SGU253 Theodore Roosevelt](https://codeforces.com/problemsets/acmsguru/problem/99999/253)
124+
* [Codeforces 55E Very simple problem](https://codeforces.com/contest/55/problem/E)
125+
* [Codeforces 166B Polygons](https://codeforces.com/problemset/problem/166/B)

src/graph/bridge-searching.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Pick an arbitrary vertex of the graph $root$ and run [depth first search](depth-
2222

2323
Now we have to learn to check this fact for each vertex efficiently. We'll use "time of entry into node" computed by the depth first search.
2424

25-
So, let $\mathtt{tin}[v]$ denote entry time for node $v$. We introduce an array $\mathtt{low}$ which will let us store the node with earliest entry time found in the DFS search that a node $v$ can reach with a single edge from itself or its descendants. $\mathtt{low}[v]$ is the minimum of $\mathtt{tin}[v]$, the entry times $\mathtt{tin}[p]$ for each node $p$ that is connected to node $v$ via a back-edge $(v, p)$ and the values of $\mathtt{low}[to]$ for each vertex $to$ which is a direct descendant of $v$ in the DFS tree:
25+
So, let $\mathtt{tin}[v]$ denote entry time for node $v$. We introduce an array $\mathtt{low}$ which will let us store the earliest entry time of the node found in the DFS search that a node $v$ can reach with a single edge from itself or its descendants. $\mathtt{low}[v]$ is the minimum of $\mathtt{tin}[v]$, the entry times $\mathtt{tin}[p]$ for each node $p$ that is connected to node $v$ via a back-edge $(v, p)$ and the values of $\mathtt{low}[to]$ for each vertex $to$ which is a direct descendant of $v$ in the DFS tree:
2626

2727
$$\mathtt{low}[v] = \min \left\{
2828
\begin{array}{l}

src/navigation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ search:
6363
- Dynamic Programming
6464
- [Introduction to Dynamic Programming](dynamic_programming/intro-to-dp.md)
6565
- [Knapsack Problem](dynamic_programming/knapsack.md)
66+
- [Longest increasing subsequence](dynamic_programming/longest_increasing_subsequence.md)
6667
- DP optimizations
6768
- [Divide and Conquer DP](dynamic_programming/divide-and-conquer-dp.md)
6869
- [Knuth's Optimization](dynamic_programming/knuth-optimization.md)
@@ -205,7 +206,6 @@ search:
205206
- Miscellaneous
206207
- Sequences
207208
- [RMQ task (Range Minimum Query - the smallest element in an interval)](sequences/rmq.md)
208-
- [Longest increasing subsequence](sequences/longest_increasing_subsequence.md)
209209
- [Search the subsegment with the maximum/minimum sum](others/maximum_average_segment.md)
210210
- [K-th order statistic in O(N)](sequences/k-th.md)
211211
- [MEX task (Minimal Excluded element in an array)](sequences/mex.md)

0 commit comments

Comments
 (0)