Aho-Corasick AC自动机
http://www.geeksforgeeks.org/aho-corasick-algorithm-pattern-searching/Part1先来加深一下对Trie的理解:structs TrieNode {
bool flag;
Trie nxt[26];
};(root) --b--> (Node) --u--> (Node) --s-->(No...
Convex hull / Andrew algorithm.
Dot Product && Cross Product.In 2D-coordinate, we have two point A(x1,y1) and B(x2,y2);A·B = A*B*Cos(θ);A×B = x1*y2 - x2*y1;A×B means the parallelogram's area by line(O->A), line(O->B). Using...
Fast Power Algorithm / Fast Matrix Exponeitation
Part 1 Just only number.We know xa+b = xa * xb.e.g. 513 = 58 x 54 x 51So we have this code:long double myPow(long double x, int pow) {
bool flag=0;
if (pow<0)
flag=1, pow=-pow;
...
Network Flow Template (SAP)
This algorithm was named for Shortest Augmenting Path (SAP).. From an OIer, at about year 2010.IntroductionTotal of n nodes, m edges.S is source node means 'source'.T is sink node means 'target'.m...