未来心不可得
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...
November 5, 2017

Heap+Dijkstra

练习题:http://poj.org/problem?id=3169Dijkstra的过程InitializationSet dist[all]=∞ and set dist[S]=0; push S into Heap;Mainwhile (!heap.empty()) { HeapItem p=heap.pop(); if (dist[p] != p.distence) ...