##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Bridges, shortest paths, LCA, centroid decomposition, and tree DP through 10 problems.
Beyond basic traversals
What you'll learn
CF 732F - maximize min edge-connectivity
Trying all orientations is exponential
Bridge tree and 2-edge-connected components
Contract $2$-edge-connected components
Bridge finding and component contraction
Linear in graph size
CF 652E - path through special edge
Query on bridge tree
Bridge tree path query
Linear preprocessing
CF 545E - minimum weight shortest path tree
Greedy edge selection in Dijkstra
Modified Dijkstra with tie-breaking
CF 450D - remove redundant railways
Checking each railway independently
Track shortest path sources
Dijkstra with path counting
Single Dijkstra run
CF 786B - edges to ranges
Too many edges
Segment tree as graph nodes
Segment tree graph
Build segment tree graph
Logarithmic edges per operation
CF 1051F - almost-tree shortest paths
Dijkstra per query is too slow
Near-tree structure exploitation
LCA on tree plus special vertices
Precompute special vertex distances
Leverages sparse extra edges
CF 609E - MST containing specific edge
Maximum edge on MST path
LCA with max edge tracking
MST plus LCA queries
CF 1495D - count valid BFS trees
Layer by layer counting
Product of valid parent counts
Quadratic in vertices
CF 771C - sum of jump distances
Quadratic pair enumeration
Modular distance counting for contribution
Contribution by distance mod k
Tree DP with mod k tracking
Linear with small k factor
CF 519E - count equidistant vertices
Linear counting per query
Find midpoint via LCA
LCA with subtree size queries
Test your understanding
What you've learned