62 lines
No EOL
2.1 KiB
Text
62 lines
No EOL
2.1 KiB
Text
---
|
|
id: tree-euler
|
|
title: "Euler Tour Technique"
|
|
author: "?"
|
|
prerequisites:
|
|
- Silver - Depth First Search
|
|
- Gold - Static Range Queries
|
|
- Gold - Point Update Range Sum
|
|
description: Flattening a tree into an array.
|
|
frequency: 2
|
|
---
|
|
|
|
import { Problem } from "../models";
|
|
|
|
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("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"], ""),
|
|
new Problem("ojuz", "IOI Regions", "IOI09_regions", "Hard", false, ["Euler-Tree", "Binary Search"], ""),
|
|
new Problem("Plat", "Snow-Cow", "973", "Hard", false, ["Euler-Tree","PURS"], ""),
|
|
]
|
|
}
|
|
};
|
|
|
|
## Introduction
|
|
|
|
<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" 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 (Method 2)" starred></resource>
|
|
<resource source="cp-algo" title="Reducing LCA to RMQ" url="graph/lca.html" starred></resource>
|
|
</resources>
|
|
|
|
(implementation)
|
|
|
|
## Problems
|
|
|
|
<problems-list problems={metadata.problems.problems} /> |