Time complexity analysis algorithm may

Usually T questions or ACM time limit is 1 second or 2 seconds.
In this case, the number of operations of the control C ++ code 10 . 7 is the best.

Given below at different data ranges, and how the time complexity of the algorithm selection code:

n≤30, index level, dfs + pruning, state compression dp

n≤100 => O(n3),floyd,dp

n≤1000 => O (n2logn) (n2) O, dp, bipartite

n≤10000 => O (n * n√), block list

n≤100000 => O (nlogn) => various Sort, segment tree, the tree array, set / map, heap, dijkstra + heap, spfa, seeking convex hull, a half plane cross-seeking, bipartite

n≤1000000 => O (n), and smaller constant O (nlogn) algorithm => hash, two-hand scan, kmp, AC automaton, a relatively small constant O (nlogn) approach: sort, Fenwick tree , heap, Dijkstra, SPFA

n≤10000000 => O (n), dual-scan pointer, kmp, AC automaton, linear sieve primes

n ≤ 10 . 9 => O (n√), a prime number is determined

n ≤ 10 18 => O (logN), the greatest common divisor matrix power quickly  met many times need to pay attention

Guess you like

Origin www.cnblogs.com/Tyouchie/p/11693614.html