##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Lazy propagation, segment tree beats, and Fenwick tree applications through 10 problems.
Range queries and updates
What you'll learn
CF 380C - bracket subsequence queries
Custom merge function
Build and query with custom merge
Standard segment tree bounds
CF 52C - range min with circular queries
Handle circular with two queries
Lazy propagation template
Logarithmic with lazy
CF 558E - sort substrings
One segment tree per letter
26 trees with lazy assignment
26 times log factor
CF 914D - GCD range queries
Linear GCD is too slow
Count bad elements
GCD segment tree with counting
Logarithmic with early exit
CF 446C - add Fibonacci to range
Adding element by element is slow
Fibonacci sequence properties for lazy propagation
Store first two Fibonacci terms
Lazy with Fibonacci pairs
Logarithmic with math
CF 438D - modulo range update
Track maximum to skip
Segment tree beats template
Amortized logarithmic
CF 459D - count inversions of frequencies
BIT for inversion counting
BIT for counting inversions
CF 61E - count decreasing triples
Two BITs for left and right counts
Coordinate compression and two passes
CF 540E - inversions after swaps
Infinite positions
Gap contribution for unchanged positions
Compress and count gaps
Handle gaps between affected positions
Based on swap count
CF 474E - longest subsequence with gap constraint
Segment tree for range max DP
Segment tree range max queries
Test your understanding
What you've learned