Concepts10

βš™οΈAlgorithmIntermediate

Debugging Strategies for CP

Systematic debugging beats guesswork: always re-read the statement, re-check constraints, and verify the output format before touching code.

#competitive programming#debugging#stress testing+12
βš™οΈAlgorithmIntermediate

Fast I/O and Optimization Tricks

Fast I/O reduces overhead from C and C++ stream synchronization and avoids unnecessary flushes, which can cut runtime by multiples on large inputs.

#fast io#iostream synchronization#cin.tie+12
βˆ‘MathIntermediate

Harmonic Lemma

The Harmonic Lemma says that the values of \lfloor n/i \rfloor only change about 2\sqrt{n} times, so you can iterate those value blocks in O(\sqrt{n}) instead of O(n).

#harmonic lemma#integer division trick#block decomposition+12
βˆ‘MathAdvanced

Divisor Function Sums

Summing the divisor function d(i) up to n equals counting lattice points under the hyperbola xy ≀ n, which can be done in O(√n) using floor-division blocks.

#divisor function#euler totient#mobius function+11
βš™οΈAlgorithmAdvanced

Divide and Conquer DP Optimization

Divide and Conquer DP optimization speeds up DP transitions of the form dp[i][j] = min over k of dp[i-1][k] + C(k, j) when the optimal k is monotone in j.

#divide and conquer dp#monge array#quadrangle inequality+10
βš™οΈAlgorithmAdvanced

Knuth Optimization

Knuth Optimization speeds up a class of interval dynamic programming (DP) from O(n^3) to O(n^2) by exploiting the monotonicity of optimal split points.

#knuth optimization#interval dp#quadrangle inequality+12
βš™οΈAlgorithmIntermediate

Interval DP

Interval DP solves problems where the optimal answer for a segment [i, j] depends on answers of its subsegments.

#interval dp#matrix chain multiplication#burst balloons+12
πŸ—‚οΈData StructureAdvanced

Wavelet Tree

A wavelet tree is a recursive data structure built over a sequence’s alphabet that answers rank, select, and quantile (k-th smallest) queries in O(log Οƒ) time, where Οƒ is the number of distinct values.

#wavelet tree#wavelet matrix#rank select+11
πŸ—‚οΈData StructureIntermediate

Merge Sort Tree

A Merge Sort Tree is a segment tree where every node stores the sorted list of values in its segment.

#merge sort tree#segment tree#range query+12
πŸ—‚οΈData StructureIntermediate

Monotonic Deque

A monotonic deque is a double-ended queue that keeps elements in increasing or decreasing order so that the front always holds the current optimum (min or max).

#monotonic deque#sliding window maximum#sliding window minimum+12