62 lines
No EOL
2.5 KiB
Text
62 lines
No EOL
2.5 KiB
Text
---
|
|
id: bin-jump
|
|
title: "Binary Jumping"
|
|
author: Benjamin Qi
|
|
description: Introduces the problems of finding level ancestors in a tree and computing the lowest common ancestors.
|
|
frequency: 3
|
|
---
|
|
|
|
import { Problem } from "../models";
|
|
|
|
export const metadata = {
|
|
problems: {
|
|
sample: [
|
|
new Problem("CSES", "Company Queries I", "1687", "Easy", false, ["Binary Jumping"], ""),
|
|
],
|
|
lca: [
|
|
new Problem("CSES", "Company Queries II", "1688", "Easy", false, ["LCA"], ""),
|
|
],
|
|
general: [
|
|
new Problem("CSES", "Planets Queries I", "1750", "Easy", false, ["Binary Jumping"], ""),
|
|
new Problem("CSES", "Distance Queries", "1135", "Easy", false, ["LCA"], ""),
|
|
new Problem("Plat", "Max Flow", "576", "Easy", false, ["LCA"], ""),
|
|
new Problem("CSA", "Root LCA Queries", "root-lca-queries", "Normal", false, ["LCA"], ""),
|
|
new Problem("CSES", "Planets Queries II", "1160", "Normal", false, ["LCA"], ""),
|
|
new Problem("Plat", "Disruption", "842", "Normal", false, ["LCA"], ""),
|
|
new Problem("DMOJ", "Hot & Cold", "bts17p7", "Normal", false, ["LCA"], ""),
|
|
new Problem("TOKI", "Functional Constraint", "https://tlx.toki.id/contests/troc-12-div-1/problems/D", "Hard", false, ["LCA"], ""),
|
|
new Problem("TOKI", "Graph & Destination", "https://tlx.toki.id/contests/troc-13-div-1/problems/E", "Hard", false, ["LCA"], ""),
|
|
new Problem("Plat", "Tree Boxes", "948", "Hard", false, ["LCA"], "interactive!!"),
|
|
new Problem("Plat", "Newbarns", "817", "Hard", false, ["Diameter"], "Copy of CF Brain Network \"Hard\": https://codeforces.com/contest/690/problem/C3"),
|
|
new Problem("Plat", "Gathering", "866", "Hard", false, ["LCA"], "interactive!!"),
|
|
new Problem("Plat", "Exercise", "901", "Very Hard", false, ["LCA"], ""),
|
|
]
|
|
}
|
|
};
|
|
|
|
## Binary Jumping
|
|
|
|
<problems-list problems={metadata.problems.sample} />
|
|
|
|
## Lowest Common Ancestor
|
|
|
|
<problems-list problems={metadata.problems.lca} />
|
|
|
|
### Tutorial
|
|
|
|
<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">
|
|
|
|
- [CF: $O(\log N)$ queries and $O(N)$ memory](https://codeforces.com/blog/entry/74847)
|
|
- [Wikipedia: $O(1)$ queries and $O(N)$ preprocessing time](https://en.wikipedia.org/wiki/Level_ancestor_problem#Ladder_algorithm)
|
|
- though explanation is not the greatest
|
|
|
|
</optional-content>
|
|
|
|
### Problems
|
|
|
|
<problems-list problems={metadata.problems.general} /> |