cf/mirror

Complexity estimator

Read the constraint (e.g. n ≤ 2·10⁵) and the time limit, and instantly see which algorithm complexities fit, are risky, or will TLE — so you pick the right approach before you start coding.

Operation budget ≈ 1.0×10⁸ comfortable · 1.0×10⁹ ceiling— aim for O(n log² n) or better
Complexity~OperationsVerdictTypical use
O(1)1 fits
O(log n)18 fits
O(√n)448 fits
O(n)2.0×10⁵ fits
O(n log n)3.5×10⁶ fitssort / heap / segment tree
O(n √n)8.9×10⁷ fitsMo's algorithm, sqrt decomp
O(n log² n)6.2×10⁷ fits
O(n²)4.0×10¹⁰ TLEnested loops / simple DP
O(n² log n)7.0×10¹¹ TLE
O(n³)8.0×10¹⁵ TLEFloyd-Warshall, matrix DP
O(2^n · n) TLEbitmask DP (n ≤ ~22)
O(n!) TLEbrute permutations (n ≤ ~11)

Heuristic: ~10⁸ simple C++ ops/sec comfortable, ~10⁹ as a risky ceiling. Constant factors, cache, and language overhead shift this — treat it as a starting point, not a guarantee.