未来心不可得
November 20, 2017

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...
November 15, 2017

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...
November 12, 2017

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...
November 7, 2017

Treap

简介Treap is Tree + Heap, each node have two property : Key, and Priority.Using key can format the Binary tree, and using Priority can make a heap.代码struct Treap { int key,pri; int cnt; T...