Concepts9

⚙️AlgorithmIntermediate

Complexity Analysis Quick Reference

Use an operation budget of about 10^8 simple operations per second on typical online judges; always multiply by the time limit and number of test files if known.

#time complexity#competitive programming#big-o+12
⚙️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

Small-to-Large Principle

Small-to-large means always merge the smaller container into the larger one to keep total work low.

#small-to-large#sack technique#dsu on tree+11
⚙️AlgorithmAdvanced

DSU on Tree (Sack)

DSU on Tree (also called the Sack technique) answers many subtree queries in O(n \log n) by keeping data from the heavy child and temporarily re-adding light subtrees.

#dsu on tree#sack technique#subtree queries+12
⚙️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

Breadth-First Search (BFS)

Breadth-First Search (BFS) explores a graph level by level, visiting all vertices at distance d from the source before any at distance d+1.

#bfs#breadth first search#graph traversal+12
⚙️AlgorithmIntermediate

0-1 BFS

0-1 BFS is a shortest path algorithm specialized for graphs whose edge weights are only 0 or 1.

#0-1 bfs#binary weights#shortest path+12
⚙️AlgorithmIntermediate

Prefix Sum and Difference Array

Prefix sums precompute running totals so any range sum [l, r] can be answered in O(1) time as prefix[r] - prefix[l-1].

#prefix sum#difference array#imos method+12
⚙️AlgorithmIntermediate

Sorting Algorithms

Sorting arranges items into a chosen order so that searching, grouping, and further algorithms become faster and simpler.

#sorting algorithms#merge sort#quicksort+12