Selected algorithm templates and solutions
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main() {
return 0;
}
n ≤ 30
, DFS + Pruning,BitMask DPn ≤ 100
=>O(n^3)
, floyd,DP,Gaussian Eliminationn ≤ 1000
=>O(n2)
,O(n^2logn)
, DP, BinarySearch,Dijkstra-B, Prim-B, Bellman-Fordn ≤ 10000
=>O(n√n)
,Unrolled Linked List, Block Partition, Mo's Algorithmn ≤ 100000
=>O(nlogn)
=> Sort, Segment Tree, Binary Indexed Tree, Set/Map, Heap, TopoSort, Dijkstra-H, Prim-H, Kruskal, SPFA, Convex Hull, BinarySearch, CDQ, Suffix array, Heavy Path Decomposition, LCTn ≤ 1000000
=>O(n)
, and low constantO(nlogn)
=> PriorityQueue, Hash, Two Pointers, Union Find, KMP, Aho–Corasick, or Sort、Binary Indexed Tree、Heap、Dijkstra、SPFAn ≤ 10000000
=>O(n)
, Two Pointers、KMP、Aho–Corasick、Sieve Primen ≤ 10^9
=>O(√n)
,Sieve Primen ≤ 10^18
=>O(logn)
,GCD, Binary Exponentiation, Decimal DPn ≤ 10^1000
=>O((logn)^2)
, High Precisionn ≤ 10100000
=>O(logk×loglogk)
, k means bits, High Precision +/-、FFT/NTT