Module Square root decomposition

Square root decomposition

**Frequency: 7/10** In square root decomposition, there are generally four types of techniques that are commonly used: - Mo's algorithm. - Dividing the array into smaller blocks of size $\sqrt{n}$. - Partitioning the data into light and heavy sets. - Processing $\sqrt{q}$ queries at a time. If these concepts are not clear to you, don't worry! By completing the problems below, you will gain a thorough understanding of what each of these techniques entails. In some OI-style data structure problems, you may find that the second-to-last subtask can be efficiently solved using square root decomposition.

Resources

- [CP Algorithms: Sqrt decomposition](https://cp-algorithms.com/data_structures/sqrt_decomposition.html#:~:text=Sqrt%20Decomposition%20is%20a%20method,%2Fmaximal%20element%2C%20etc.)

Problems

Frequency 228 / 266 1400
Tree query 217 / 224 1500
Inversions query 131 / 149 1500
Nearest vertex 122 / 132 1600
Dominating color 89 / 103 1700
String occurences 3 84 / 94 1700
Inversions query 2 65 / 72 1700
Pair 52 / 62 1700
Sparse update 52 / 56 1800
Tree 39 / 40 1900
Range query 50 / 58 1900
String concatenation 83 / 119 1900
Subarray distance 14 / 28 2000
Chameleon 41 / 48 2000
Knapsack 75 / 101 2000
Bit counting 10 / 11 2000
Subsequence queries 23 / 29 2100
Sub-subsequence 7 / 11 2100
Delete numbers 14 / 17 2200
Mode 53 / 64 2200
Marisa is happy 14 / 55 2200
Inversions query 3 8 / 11 2300
Upperbound 4 / 5 2300
23 path 11 / 14 2300
Yet another square root decomposition problem 23 / 26 2400
Marisa plays poker 38 / 41 2400
Wonderful world 22 / 26 2400