more conversion
This commit is contained in:
parent
bf255f9f50
commit
98fe8d54c4
|
@ -25,6 +25,7 @@ export const metadata = {
|
|||
new Problem("CSES", "Tree Distances II", "1133", "Normal", false, ["Tree", "DFS"]),
|
||||
new Problem("CF", "Wizard's Tour", "contest/860/problem/D", "Normal", false, ["Tree", "DFS"]),
|
||||
new Problem("POI", "Hotels", "https://szkopul.edu.pl/problemset/problem/gDw3iFkeVm7ZA3j_16-XR7jI/site/?key=statement", "Normal", false, ["Tree", "DFS"]),
|
||||
new Problem("HE", "Birthday Gifts", "https://www.hackerearth.com/practice/math/combinatorics/inclusion-exclusion/practice-problems/algorithm/mancunian-and-birthday-gifts-d44faa15/description/", "Normal", false, ["Tree", "PIE"], ""),
|
||||
new Problem("CSA", "Tree Construction", "contest/860/problem/D", "Hard", false, ["Tree", "DFS"], "several cases"),
|
||||
],
|
||||
general: [
|
||||
|
@ -51,12 +52,6 @@ export const metadata = {
|
|||
|
||||
<problems-list problems={metadata.problems.sample} />
|
||||
|
||||
<info-block title="Pro Tip">
|
||||
|
||||
Quite frequent at the Silver level.
|
||||
|
||||
</info-block>
|
||||
|
||||
## Tutorial
|
||||
|
||||
- Recommended:
|
||||
|
|
|
@ -3,8 +3,7 @@ id: cyc
|
|||
title: Cycle Detection
|
||||
author: Siyong Huang
|
||||
prerequisites:
|
||||
- Silver - Functional Graphs
|
||||
- Gold - Breadth First Search
|
||||
- Gold - Topological Sort
|
||||
description: A simple cycle is a non-empty path of distinct edges that start and end at the same vertex such that no vertex appears more than once. Describes how to detect cycles in both directed and undirected graphs.
|
||||
frequency: 0
|
||||
---
|
||||
|
@ -32,13 +31,17 @@ export const metadata = {
|
|||
|
||||
<problems-list problems={metadata.problems.und} />
|
||||
|
||||
BFS-Cycle?
|
||||
<optional-content title="+1 Approximation for Shortest Cycle">
|
||||
|
||||
An algorithm known as **BFS-Cycle** returns an integer that is at most one more than the length of the shortest cycle in $O(N^2)$ time; see page 4 [here](https://people.csail.mit.edu/virgi/6.890/lecture9.pdf) for details.
|
||||
|
||||
</optional-content>
|
||||
|
||||
## Directed Graphs
|
||||
|
||||
<problems-list problems={metadata.problems.dir} />
|
||||
|
||||
The same general idea is implemented below to find any cycle in a directed graph (if one exists).
|
||||
The same general idea is implemented below to find any cycle in a directed graph (if one exists). Note that this is almost identical to the DFS algorithm for topological sorting.
|
||||
|
||||
```cpp
|
||||
//UNTESTED
|
||||
|
|
|
@ -62,11 +62,11 @@ Usually, at least one problem from every gold division contest involves some sor
|
|||
The following tutorials serve as an introduction into the mindset of DP.
|
||||
|
||||
<resources>
|
||||
<resource source="CPH" title="7 - DP" starred>Great introduction that covers most classical problems</resource>
|
||||
<resource source="CPH" title="7 - DP" starred>great introduction that covers most classical problems</resource>
|
||||
<resource source="TC" title="DP from Novice to Advanced" url="dynamic-programming-from-novice-to-advanced">great for all skill levels</resource>
|
||||
<resource source="CPC" title="6 - DP" url="06_dynamic_programming">examples with nonclassical problems</resource>
|
||||
<resource source="HR" title="DP" url="https://www.hackerrank.com/topics/dynamic-programming">also covers many classical problems</resource>
|
||||
<resource source="PAPS" title="9 - DP"></resource>
|
||||
<resource source="PAPS" title="9 - DP">starts with DAGs, which are covered in "Topological Sort"</resource>
|
||||
</resources>
|
||||
|
||||
Practice makes perfect. Start by doing some classical problems (try at least one of each), as these are **must know** DP problems. Each topic starts with direct applications of the classical problems, and then some interesting variations and USACO problems which utilize the ideas. Solutions for most problems (excluding USACO) can be found on Chapter 7 of CPH.
|
||||
|
|
|
@ -48,6 +48,8 @@ export const metadata = {
|
|||
|
||||
</optional-content>
|
||||
|
||||
Note: You may prefer to use this in place of DFS for computing connected components.
|
||||
|
||||
## Problems
|
||||
|
||||
<problems-list problems={metadata.problems.general} />
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
---
|
||||
id: hashing
|
||||
title: "Hashing"
|
||||
author: Benjamin Qi
|
||||
description: Quickly test equality of substrings with a small probability of failure.
|
||||
frequency: 1
|
||||
---
|
||||
|
||||
## Tutorial
|
||||
|
||||
- [PAPS 14.3](https://www.csc.kth.se/~jsannemo/slask/main.pdf)
|
||||
- CPH 26.3
|
||||
- [cp-algorithms String Hashing](https://cp-algorithms.com/string/string-hashing.html)
|
||||
|
||||
My implementation can be found [here](https://github.com/bqi343/USACO/blob/master/Implementations/content/strings%20(14)/Light/HashRange%20(14.2).h). It uses two bases rather than just one to decrease the probability that two random strings hash to the same value. As mentioned in the articles above, there is no need to calculate modular inverses.
|
||||
|
||||
## Hacking
|
||||
|
||||
- [Anti-Hash Tests](https://codeforces.com/blog/entry/60442)
|
||||
- On CodeForces educational rounds in particular, make sure to use random bases.
|
||||
|
||||
## Problems
|
||||
|
||||
- USACO
|
||||
- [Gold Cownomics](http://www.usaco.org/index.php?page=viewproblem2&cpid=741)
|
||||
- Use two pointers; for a fixed $l$, keep extending $r$ to the right until the positions $l\ldots r$ explain spotiness.
|
||||
- Hashing gives you a way to quickly check whether two substrings of different cow types are equal. So for a single $[l,r]$ pair you can check whether it works in $O(N\log N)$ time (and you only need to check $O(M)$ of these pairs in total).
|
||||
- Actually, it's possible to pass $O(N^2M)$ (or even slower) solutions.
|
||||
- [Gold Lightsout](http://www.usaco.org/index.php?page=viewproblem2&cpid=599)
|
||||
- figure out whether this actually needs hashing? (check ...)
|
||||
- Other (check ...)
|
||||
- [Palindromic Partitions](https://csacademy.com/contest/ceoi-2017-day-2/task/palindromic-partitions/)
|
||||
- [Liar](http://codeforces.com/problemset/problem/822/E) [](93)
|
||||
- [Palindromic Characteristics](http://codeforces.com/problemset/problem/835/D) [](100)
|
||||
- [Berland SU Computer Network](http://codeforces.com/contest/847/problem/L) [](142)
|
|
@ -21,6 +21,7 @@ export const metadata = {
|
|||
new Problem("Old Silver", "SuperBull", "531", "Easy", false, ["MST"], ""),
|
||||
new Problem("Gold", "Walk", "946", "Easy", false, ["Math","Prim"], ""),
|
||||
new Problem("Gold", "Fencedin", "623", "Easy", false, ["MST"], ""),
|
||||
new Problem("HR", "Spanning Tree Fraction", "https://www.hackerrank.com/contests/w31/challenges/spanning-tree-fraction/problem", "Easy", false, ["MST", "Binary Search"], ""),
|
||||
new Problem("Plat", "Fencedin", "625", "Normal", false, ["Kruskal"], ""),
|
||||
],
|
||||
}
|
||||
|
@ -33,18 +34,13 @@ export const metadata = {
|
|||
## Tutorial
|
||||
|
||||
<resources>
|
||||
<resource source="CPH" title="15 - Spanning Trees"></resource>
|
||||
<resource source="PAPS" title="12.4"></resource>
|
||||
<resource source="cp-algo" title="Prim's" url="graph/mst_prim.html">Similar to Dijkstra</resource>
|
||||
<resource source="CPH" title="15 - Spanning Trees" starred>Kruskal's & Prim's</resource>
|
||||
<resource source="PAPS" title="12.4">Kruskal's</resource>
|
||||
<resource source="cp-algo" title="Prim's" url="graph/mst_prim.html"></resource>
|
||||
<resource source="cp-algo" title="Kruskal's" url="graph/mst_kruskal.html"></resource>
|
||||
<resource source="cp-algo" title="Kruskal's" url="graph/mst_kruskal_with_dsu.html"></resource>
|
||||
</resources>
|
||||
|
||||
## USACO Problems
|
||||
|
||||
<problems-list problems={metadata.problems.general} />
|
||||
|
||||
## Other Problems
|
||||
|
||||
- [Birthday Gifts](https://www.hackerearth.com/practice/math/combinatorics/inclusion-exclusion/practice-problems/algorithm/mancunian-and-birthday-gifts-d44faa15/) [](73)
|
||||
- [Spanning Tree Fraction](https://www.hackerrank.com/contests/w31/challenges/spanning-tree-fraction) [](78)
|
||||
<problems-list problems={metadata.problems.general} />
|
|
@ -14,7 +14,7 @@ export const metadata = {
|
|||
sample: [
|
||||
new Problem("YS", "Point Set Range Composite", "point_set_range_composite", "Intro", false, ["PURQ"], ""),
|
||||
],
|
||||
probs: [
|
||||
general: [
|
||||
new Problem("CSES", "Range Minimum Queries II", "1649", "Intro", false, ["PURQ"], ""),
|
||||
new Problem("Gold", "Springboards", "995", "Normal", false, ["PURQ"], "min segtree"),
|
||||
new Problem("Plat", "Nocross", "721", "Normal", false, ["PURQ"], "LIS variation"),
|
||||
|
@ -24,6 +24,8 @@ export const metadata = {
|
|||
|
||||
<problems-list problems={metadata.problems.sample} />
|
||||
|
||||
<br/>
|
||||
|
||||
A **segment tree** allows you to do point update and range query in $O(\log N)$ time each for any associative operation.
|
||||
|
||||
<info-block title="Pro Tip">
|
||||
|
@ -35,11 +37,11 @@ For gold, you only need to know the basics (ex. sum, min queries). More advanced
|
|||
### Tutorials
|
||||
|
||||
<resources>
|
||||
<resource source="CPH" title="9.3 - Segment Trees"></resource>
|
||||
<resource source="PAPS" title="11.2.3"></resource>
|
||||
<resource source="CF" title="Efficient and easy segment trees" url="blog/entry/18051"></resource>
|
||||
<resource source="CSA" title="Segment Trees" url="segment_trees"></resource>
|
||||
<resource source="CSA" title="Segment Trees" url="segment_trees" starred>interactive</resource>
|
||||
<resource source="CF" title="Efficient and easy segment trees" url="blog/entry/18051" starred>simple implementation</resource>
|
||||
<resource source="CPH" title="9.3 - Segment Trees" starred>same implementation as above</resource>
|
||||
<resource source="cp-algo" title="Segment Tree" url="data_structures/segment_tree.html"></resource>
|
||||
<resource source="PAPS" title="11.2.3"></resource>
|
||||
<resource source="CPC" title="3 - Data Structures" url="03_data_structures"></resource>
|
||||
</resources>
|
||||
|
||||
|
|
|
@ -54,9 +54,9 @@ Aka *Fenwick Tree*.
|
|||
### Tutorials
|
||||
|
||||
<resources>
|
||||
<resource source="CPH" title="9.2, 9.4 - Binary Indexed Tree">very good</resource>
|
||||
<resource source="CSA" title="Fenwick Trees" url="fenwick_trees">also very good</resource>
|
||||
<resource source="cp-algo" title="Fenwick Tree" url="data_structures/fenwick.html">extends to range increment and range query, which is covered in plat</resource>
|
||||
<resource source="CSA" title="Fenwick Trees" url="fenwick_trees" starred>interactive</resource>
|
||||
<resource source="CPH" title="9.2, 9.4 - Binary Indexed Tree" starred>similar to above</resource>
|
||||
<resource source="cp-algo" title="Fenwick Tree" url="data_structures/fenwick.html">also similar to above</resource>
|
||||
<resource source="TC" title="Binary Indexed Trees" url="binary-indexed-trees"></resource>
|
||||
</resources>
|
||||
|
||||
|
|
|
@ -43,12 +43,12 @@ Use *Dijkstra's Algorithm*.
|
|||
|
||||
### Tutorial
|
||||
|
||||
- CSES 13.2
|
||||
- [PAPS 12.3.1](https://www.csc.kth.se/~jsannemo/slask/main.pdf)
|
||||
- [cp-algo Dijkstra (Dense Graphs)](https://cp-algorithms.com/graph/dijkstra_sparse.html)
|
||||
- [cp-algo Dijkstra (Sparse Graphs)](https://cp-algorithms.com/graph/dijkstra_sparse.html)
|
||||
- Usually, it's this one that's applicable.
|
||||
- [CPC.8](https://github.com/SuprDewd/T-414-AFLV/tree/master/08_graphs_2)
|
||||
<resources>
|
||||
<resource source="CPH" title="13.2 - Dijkstra" starred>code</resource>
|
||||
<resource source="cp-algo" title="Dijkstra (Dense Graphs)" url="graph/dijkstra_dense.html"></resource>
|
||||
<resource source="cp-algo" title="Dijkstra (Sparse Graphs)" url="graph/dijkstra_sparse.html"></resource>
|
||||
<resource source="CPC" title="8 - Graphs 2" url="08_graphs_2"></resource>
|
||||
</resources>
|
||||
|
||||
### $O(M\log N)$ implementation
|
||||
|
||||
|
@ -72,19 +72,30 @@ Can be done in $O(M+N\log N)$ with Fibonacci heap.
|
|||
|
||||
Use the *Floyd-Warshall* algorithm.
|
||||
|
||||
### Standard
|
||||
|
||||
- [CSES Shortest Routes II](https://cses.fi/problemset/task/1672)
|
||||
|
||||
### Tutorial
|
||||
|
||||
- CPH 13.3
|
||||
- [PAPS 12.3.3](https://www.csc.kth.se/~jsannemo/slask/main.pdf)
|
||||
- [cp-algo Floyd-Warshall](https://cp-algorithms.com/graph/all-pair-shortest-path-floyd-warshall.html)
|
||||
<resources>
|
||||
<resource source="CPH" title="13.3 - Floyd-Warshall" starred>example calculation, code</resource>
|
||||
<resource source="PAPS" title="12.3.3"></resource>
|
||||
<resource source="cp-algo" title="Floyd-Warshall" url="graph/all-pair-shortest-path-floyd-warshall.html"></resource>
|
||||
</resources>
|
||||
|
||||
<optional-content title="Incorrect Floyd-Warshall">
|
||||
|
||||
[Paper](https://arxiv.org/pdf/1904.01210.pdf)
|
||||
|
||||
> A common mistake in implementing the Floyd–Warshall algorithm is to
|
||||
misorder the triply nested loops (The correct order is `KIJ`). The incorrect
|
||||
`IJK` and `IKJ` algorithms do not give correct solutions for some instance. However, we can prove that if these are repeated three times, we obtain the correct solutions.
|
||||
>
|
||||
> It would be emphasized that these fixes (repeating incorrect algorithms three
|
||||
times) have the same time complexity as the correct Floyd–Warshall algorithm
|
||||
up to constant factors. Therefore, our results suggest that, if one is confused by
|
||||
the order of the triply nested loops, one can repeat the procedure three times
|
||||
just to be safe.
|
||||
|
||||
</optional-content>
|
||||
|
||||
### Problems
|
||||
|
||||
<problems-list problems={metadata.problems.apsp} />
|
||||
|
||||
- [USACO Moortal Cowmbat](http://usaco.org/index.php?page=viewproblem2&cpid=971)
|
||||
- Use APSP before running DP.
|
||||
<problems-list problems={metadata.problems.apsp} />
|
|
@ -36,8 +36,8 @@ First we'll consider the special case when $\ominus$ denotes `min`.
|
|||
### Tutorial
|
||||
|
||||
<resources>
|
||||
<resource source="CPH" title="9.1 - Static Array Queries"></resource>
|
||||
<resource source="PAPS" title="11.2.2 - Sparse Tables"></resource>
|
||||
<resource source="CPH" title="9.1 - Minimum Queries" starred>diagrams</resource>
|
||||
<resource source="PAPS" title="11.2.2 - Sparse Tables" starred>code</resource>
|
||||
<resource source="cp-algo" title="RMQ" url="sequences/rmq.html"></resource>
|
||||
<resource source="cp-algo" title="Sparse Table" url="data_structures/sparse-table.html"></resource>
|
||||
</resources>
|
||||
|
|
61
content/5_Gold/String_Hashing.mdx
Normal file
61
content/5_Gold/String_Hashing.mdx
Normal file
|
@ -0,0 +1,61 @@
|
|||
---
|
||||
id: hashing
|
||||
title: "Hashing"
|
||||
author: Benjamin Qi
|
||||
description: Quickly test equality of substrings with a small probability of failure.
|
||||
frequency: 1
|
||||
---
|
||||
|
||||
import { Problem } from "../models";
|
||||
|
||||
export const metadata = {
|
||||
problems: {
|
||||
ex: [
|
||||
new Problem("Gold", "Cownomics", "741", "Easy", false, [], ""),
|
||||
],
|
||||
general: [
|
||||
new Problem("CSA", "Palindromic Partitions", "palindromic-partitions", "Easy", false, ["Greedy", "Hashing"], ""),
|
||||
new Problem("CF", "Palindromic Characteristics", "problemset/problem/835/D", "Easy", false, ["DP", "Hashing"], ""),
|
||||
new Problem("CF", "Liar", "problemset/problem/822/E", "Hard", false, ["DP", "Hashing"], ""),
|
||||
],
|
||||
adj: [
|
||||
new Problem("CF", "Berland SU Computer Network", "contest/847/problem/L", "Normal", false, [], ""),
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
## Tutorial
|
||||
|
||||
<resources>
|
||||
<resource source="CPH" title="26.3 - String Hashing" starred>good intro</resource>
|
||||
<resource source="cp-algo" title="String Hashing" url="string/string-hashing.html" starred>code</resource>
|
||||
<resource source="PAPS" title="14.3 - Hashing" starred>many applications</resource>
|
||||
|
||||
</resources>
|
||||
|
||||
My implementation can be found [here](https://github.com/bqi343/USACO/blob/master/Implementations/content/strings%20(14)/Light/HashRange%20(14.2).h). It uses two bases rather than just one to decrease the probability that two random strings hash to the same value. As mentioned in the articles above, there is no need to calculate modular inverses.
|
||||
|
||||
## Example: Cownomics (Gold)
|
||||
|
||||
<problems-list problems={metadata.problems.ex} />
|
||||
|
||||
- Use two pointers; for a fixed $l$, keep extending $r$ to the right until the positions $l\ldots r$ explain spotiness.
|
||||
- Hashing gives you a way to quickly check whether two substrings of different cow types are equal. So for a single $[l,r]$ pair you can check whether it works in $O(N\log N)$ time (and you only need to check $O(M)$ of these pairs in total).
|
||||
- Actually, it's possible to pass $O(N^2M)$ (or even slower) solutions.
|
||||
|
||||
## Adjacency Lists
|
||||
|
||||
(elaborate)
|
||||
|
||||
<problems-list problems={metadata.problems.adj} />
|
||||
|
||||
## Hacking
|
||||
|
||||
<resources>
|
||||
<resource source="CF" title="dacin21 - Anti-Hash Tests" url="blog/entry/60442">On CodeForces educational rounds in particular, make sure to randomize your bases.</resource>
|
||||
</resources>
|
||||
|
||||
## Problems
|
||||
|
||||
<problems-list problems={metadata.problems.general} />
|
||||
|
|
@ -37,16 +37,27 @@ To review, a **directed** graph consists of edges that can only be traversed in
|
|||
|
||||
A [topological sort](https://en.wikipedia.org/wiki/Topological_sorting) of a directed acyclic graph is a linear ordering of its vertices such that for every directed edge $u\to v$ from vertex $u$ to vertex $v$, $u$ comes before $v$ in the ordering.
|
||||
|
||||
### Tutorial
|
||||
## Tutorial
|
||||
|
||||
<resources>
|
||||
<resource source="CSA" title="Topological Sorting" url="topological_sorting" starred>both BFS, DFS</resource>
|
||||
</resources>
|
||||
|
||||
### DFS
|
||||
|
||||
<resources>
|
||||
<resource source="CPH" title="16.1, 16.2 - Topological Sorting">DFS</resource>
|
||||
<resource source="cp-algo" title="Topological Sort" url="graph/topological-sort.html">DFS</resource>
|
||||
<resource source="CSA" title="Topological Sorting" url="topological_sorting" starred>both BFS, DFS</resource>
|
||||
</resources>
|
||||
|
||||
(implementation)
|
||||
|
||||
### BFS
|
||||
|
||||
The BFS version, known as [Kahn's Algorithm](https://en.wikipedia.org/wiki/Topological_sorting#Kahn's_algorithm), makes it obvious how to extract the lexicographically minimum topological sort.
|
||||
|
||||
(implementation)
|
||||
|
||||
## Dynamic Programming
|
||||
|
||||
<resources>
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
---
|
||||
id: tree-euler
|
||||
title: "Euler Tour on Tree"
|
||||
title: "Euler Tour Technique"
|
||||
author: "?"
|
||||
prerequisites:
|
||||
- Silver - Depth First Search
|
||||
- Gold - Static Range Queries
|
||||
- Gold - Point Update Range Sum
|
||||
description: Subtree updates and queries as well as a way to compute lowest common ancestors.
|
||||
description: Flattening a tree into an array.
|
||||
frequency: 2
|
||||
---
|
||||
|
||||
|
@ -16,13 +16,13 @@ export const metadata = {
|
|||
problems: {
|
||||
sample: [
|
||||
new Problem("CSES", "Subtree Queries", "1137", "Easy", false, ["Euler-Tree"], "equivalent to https://judge.yosupo.jp/problem/vertex_add_subtree_sum"),
|
||||
new Problem("CSES", "Path Queries", "1138", "Easy", false, ["Euler-Tree","PURS"], "equivalent to https://judge.yosupo.jp/problem/vertex_add_path_sum"),
|
||||
],
|
||||
lca: [
|
||||
new Problem("CSES", "Company Queries II", "1688", "Easy", false, ["LCA"], ""),
|
||||
new Problem("CSES", "Distance Queries", "1135", "Easy", false, ["LCA"], ""),
|
||||
],
|
||||
problems: [
|
||||
new Problem("CSES", "Distance Queries", "1135", "Easy", false, ["LCA"], ""),
|
||||
new Problem("CSES", "Path Queries", "1138", "Easy", false, ["Euler-Tree","PURS"], "equivalent to https://judge.yosupo.jp/problem/vertex_add_path_sum"),
|
||||
new Problem("Gold", "Cow Land", "921", "Normal", false, ["Euler-Tree","PURS", "HLD"], ""),
|
||||
new Problem("Gold", "Milk Visits", "970", "Normal", false, ["Euler-Tree", "LCA"], ""),
|
||||
new Problem("Plat", "Promotion Counting", "696", "Normal", false, ["Euler-Tree","PURS"], ""),
|
||||
|
@ -36,19 +36,23 @@ export const metadata = {
|
|||
|
||||
<problems-list problems={metadata.problems.sample} />
|
||||
|
||||
If we can preprocess a rooted tree such that every subtree corresponds to a contiguous range on an array, we can do updates and range queries on it!
|
||||
|
||||
### Tutorial
|
||||
|
||||
<resources>
|
||||
<resource source="CPH" title="18.2 - Subtrees & Paths"></resource>
|
||||
<resource source="CPH" title="18.2 - Subtrees & Paths" starred>introduces tree traversal array</resource>
|
||||
</resources>
|
||||
|
||||
## LCA
|
||||
|
||||
<problems-list problems={metadata.problems.lca} />
|
||||
|
||||
### Tutorial
|
||||
|
||||
<resources>
|
||||
<resource source="CPH" title="18.3 - Least Common Ancestor"></resource>
|
||||
<resource source="cp-algo" title="LCA with Sparse Table" url="graph/lca.html"></resource>
|
||||
<resource source="CPH" title="18.3 - Least Common Ancestor (Method 2)" starred></resource>
|
||||
<resource source="cp-algo" title="Reducing LCA to RMQ" url="graph/lca.html" starred></resource>
|
||||
</resources>
|
||||
|
||||
(implementation)
|
||||
|
|
|
@ -42,8 +42,10 @@ export const metadata = {
|
|||
|
||||
### Tutorial
|
||||
|
||||
- CPH 18.1, 18.3
|
||||
- [cp-algorithms](https://cp-algorithms.com/)
|
||||
<resources>
|
||||
<resource source="CPH" title="18.1, 18.3 (Method 1) - Finding Ancestors" starred></resource>
|
||||
<resource source="cp-algo" title="LCA with Binary Lifting" url="graph/lca_binary_lifting.html"> </resource>
|
||||
</resources>
|
||||
|
||||
<optional-content title="Improvements">
|
||||
|
||||
|
|
|
@ -26,8 +26,10 @@ export const metadata = {
|
|||
|
||||
### Tutorial
|
||||
|
||||
- [GeeksForGeeks](http://www.geeksforgeeks.org/centroid-decomposition-of-tree/)
|
||||
- [Carpanese](https://medium.com/carpanese/an-illustrated-introduction-to-centroid-decomposition-8c1989d53308)
|
||||
<resources>
|
||||
<resource source="Carpanese" title="Illustrated Intro to Centroid Decomposition" url="https://medium.com/carpanese/an-illustrated-introduction-to-centroid-decomposition-8c1989d53308" starred></resource>
|
||||
<resource source="GFG" title="Centroid Decomposition of Tree" url="centroid-decomposition-of-tree"></resource>
|
||||
</resources>
|
||||
|
||||
### Problems
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
id: geo-pri
|
||||
title: "Geometry Primitives"
|
||||
author: Benjamin Qi
|
||||
description: Basic setup for geometry problems and introduction to line sweep.
|
||||
description: Basic setup for geometry problems.
|
||||
---
|
||||
|
||||
## Primitives
|
||||
|
@ -13,7 +13,7 @@ You should know basic operations like cross product and dot product. For platinu
|
|||
|
||||
<resources>
|
||||
<resource source="CPC" title="12 - geometry" url="12_geometry">basics, polygon area, point in polygon</resource>
|
||||
<resource source="CPH" title="29, 30.1, 30.2 - Geometry, Sweep Line Algorithms"></resource>
|
||||
<resource source="CPH" title="29"></resource>
|
||||
<resource source="TC" title="Basic Geometry Concepts" url="geometry-concepts-basic-concepts"></resource>
|
||||
<resource source="CF" title="Point Class" url="blog/entry/48122"></resource>
|
||||
<resource source="CF" title="C++ - std::complex" url="blog/entry/22175"></resource>
|
||||
|
@ -39,16 +39,3 @@ You should know basic operations like cross product and dot product. For platinu
|
|||
- [Birthday Cake](https://open.kattis.com/problems/birthdaycake)
|
||||
- [Racing Off Track](https://open.kattis.com/contests/acpc17open/problems/racingofftrack)
|
||||
- [TopCoder Watchtower](https://community.topcoder.com/stat?c=problem_statement&pm=2014&rd=4685)
|
||||
|
||||
## Sweep Line
|
||||
|
||||
### Tutorial
|
||||
|
||||
- CPH 30
|
||||
- [TopCoder Line Sweep](https://www.topcoder.com/community/competitive-programming/tutorials/line-sweep-algorithms/)
|
||||
|
||||
### Problems
|
||||
|
||||
- [Cow Steepchase II (Silver)](http://www.usaco.org/index.php?page=viewproblem2&cpid=943)
|
||||
- :|
|
||||
- [Kattis Closest Pair](https://open.kattis.com/problems/closestpair2)
|
||||
|
|
|
@ -3,7 +3,7 @@ id: hld
|
|||
title: "Heavy-Light Decomposition"
|
||||
author: Benjamin Qi
|
||||
prerequisites:
|
||||
- Gold - Euler Tour on Tree
|
||||
- Gold - Euler Tour Technique
|
||||
- Platinum - Range Update Range Query
|
||||
description: Path and subtree updates and queries.
|
||||
frequency: 1
|
||||
|
@ -14,25 +14,28 @@ import { Problem } from "../models";
|
|||
export const metadata = {
|
||||
problems: {
|
||||
sample: [
|
||||
new Problem("CSES", "Company Queries II", "1688", "Easy", false, ["LCA"], ""),
|
||||
new Problem("YS","Vertex Set Path Composite","vertex_set_path_composite", "Normal", false, ["HLD"], ""),
|
||||
new Problem("CSES", "Company Queries II", "1688", "Intro", false, ["LCA"], ""),
|
||||
new Problem("YS","Vertex Set Path Composite","vertex_set_path_composite", "Easy", false, ["HLD"], ""),
|
||||
],
|
||||
general: [
|
||||
new Problem("Gold", "Cow Land", "921", "Normal", false, ["Euler-Tree","PURS", "HLD"], ""),
|
||||
new Problem("Plat", "Disrupt", "842", "Easy", false, ["HLD"]),
|
||||
new Problem("Gold", "Cow Land", "921", "Easy", false, ["Euler-Tree","PURS", "HLD"], ""),
|
||||
new Problem("Plat", "Disrupt", "842", "Easy", false, ["HLD"], ""),
|
||||
new Problem("Old Gold", "Grass Planting", "102", "Easy", false, ["HLD"], ""),
|
||||
new Problem("HR", "Subtrees & Paths", "https://www.hackerrank.com/challenges/subtrees-and-paths", "Easy", false, ["HLD"], ""),
|
||||
new Problem("ojuz", "JOI - Cats or Dogs", "https://oj.uz/problem/view/JOI18_catdog", "Hard", false, ["HLD"], ""),
|
||||
],
|
||||
}
|
||||
};
|
||||
|
||||
<problems-list problems={metadata.problems.sample} />
|
||||
|
||||
(computing LCA, path composite)
|
||||
|
||||
## Tutorial
|
||||
|
||||
- [Anudeep2011](https://blog.anudeep2011.com/heavy-light-decomposition/)
|
||||
- [AI-Cash](http://codeforces.com/blog/entry/22072)
|
||||
- [adamant](https://codeforces.com/blog/entry/53170)
|
||||
<resources>
|
||||
<resource source="anudeep2011" title="HLD" url="https://blog.anudeep2011.com/heavy-light-decomposition/" starred>explains what HLD is (but incomplete & overly complicated code)</resource>
|
||||
<resource source="CF" title="AI-Cash - HLD Implementation" url="blog/entry/22072" starred></resource>
|
||||
<resource source="CF" title="adamant - Easiest HLD with subtree queries" url="blog/entry/53170" starred></resource>
|
||||
</resources>
|
||||
|
||||
## Problems
|
||||
|
||||
|
|
|
@ -24,10 +24,12 @@ export const metadata = {
|
|||
|
||||
## Additional Reading
|
||||
|
||||
- CPH 18.4 - Merging Data Structures
|
||||
- CF Blogs
|
||||
- [Arpa](https://codeforces.com/blog/entry/44351)
|
||||
- [tuwuna](https://codeforces.com/blog/entry/67696)
|
||||
|
||||
<resources>
|
||||
<resource source="CPH" title="18.4 - Merging Data Structures"></resource>
|
||||
<resource source="CF" title="Arpa - Sack (DSU on Tree)" url="blog/entry/44351"></resource>
|
||||
<resource source="CF" title="tuwuna - Explaining DSU on Trees" url="blog/entry/67696"></resource>
|
||||
</resources>
|
||||
|
||||
# Merging Sets
|
||||
|
||||
|
|
34
content/6_Plat/Sweep_Line.mdx
Normal file
34
content/6_Plat/Sweep_Line.mdx
Normal file
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
id: sweep-line
|
||||
title: "Sweep Line"
|
||||
author: Benjamin Qi
|
||||
description: Introduction to line sweep.
|
||||
---
|
||||
|
||||
## Sweep Line
|
||||
|
||||
<resources>
|
||||
<resource source="CPH" title="30.1, 30.2 - Sweep Line Algorithms"></resource>
|
||||
</resources>
|
||||
|
||||
### Tutorial
|
||||
|
||||
- CPH 30
|
||||
- [TopCoder Line Sweep](https://www.topcoder.com/community/competitive-programming/tutorials/line-sweep-algorithms/)
|
||||
|
||||
## Closest Pair
|
||||
|
||||
- [Kattis Closest Pair](https://open.kattis.com/problems/closestpair2)
|
||||
|
||||
## Line Segment Intersection
|
||||
|
||||
- [Cow Steepchase II (Silver)](http://www.usaco.org/index.php?page=viewproblem2&cpid=943)
|
||||
- :|
|
||||
|
||||
## Manhattan MST
|
||||
|
||||
https://open.kattis.com/problems/gridmst
|
||||
|
||||
CSA 84 The Sprawl
|
||||
|
||||
TC 760 ComponentsForever
|
|
@ -155,6 +155,7 @@ const ModuleOrdering: {[key: string]: ModuleOrderingItem[]} = {
|
|||
name: "Geometry",
|
||||
items: [
|
||||
"geo-pri",
|
||||
"sweep-line",
|
||||
"hull",
|
||||
"LC",
|
||||
"lagrange",
|
||||
|
|
Reference in a new issue