模板
文章平均质量分 58
fire__ice
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
字典树模板
使用说明:t[string]存的是string的个数,insert(string)可以访问string的下标 #include #include #include #include using namespace std; struct Node{ int index; struct Node *next[27]; Node(){ index = 0; memset(next原创 2012-04-17 20:51:50 · 453 阅读 · 2 评论 -
邻接表模板
template class Graph{ public: void Clear(){ pos = 0; CLR(H,-1); } void add(int u,int v,int c){ Num[pos] = v; Len[pos] = c; Next[pos] = H[u]; H[u] = pos++; } int H[MaxV],Num[MaxE],Len[Ma原创 2012-05-04 19:52:38 · 1190 阅读 · 3 评论 -
最短路(Dijkstra+优先队列)
const int INF = 0xfffffff; const int M = 1005; Graph g; int Dis[M]; struct Node{ Node(){} Node(int Len, int Ind):len(Len),ind(Ind){} int len,ind; bool operator<(const Node& node) const{ return原创 2012-05-11 10:20:10 · 760 阅读 · 0 评论 -
强连通缩点
使用说明:需要邻接表模板,强连通模板,头文件string.h 宏定义#define CLR(arr,v) memset(arr,v,sizeof(arr)) 在执行强连通模板后,执行缩点模板把缩过点后的图存到邻接表g1中。 Graph g1; void BuiltGraph(int n) { g1.Clear(); for(int i = 1;i <= n;++i) for(int原创 2012-05-11 16:41:28 · 860 阅读 · 0 评论 -
最小生成树模板(Prim+优先队列)
const int INF = 0xfffffff; const int M = 1005; Graph g; int Dis[M]; bool Vist[M]; struct Node{ Node(){} Node(int Len, int Ind):len(Len),ind(Ind){} int len,ind; bool operator<(const Node& node) co原创 2012-05-11 10:48:15 · 731 阅读 · 0 评论 -
强连通模板(Tarjan)
使用说明:需要邻接表模板 ,头文件string.h 宏定义#define CLR(arr,v) memset(arr,v,sizeof(arr)) const int M = 105 ; Graph g; int Connect[M],Low[M],Ind[M],Stack[M],InStack[M],ConnectNum,top,ind; void Dfs(int cur) { Low原创 2012-05-11 16:38:08 · 869 阅读 · 0 评论 -
二分图模板
const int M = 505; Graph g; class MaxNumMatch{ public: void Clear(){ CLR(Match,-1); g.Clear(); } int GetMaxNumMatch(int s,int t){ int MatchNum = 0; for(int i = s;i <= t;++i){ CLR(Vist,fals原创 2012-05-09 09:41:13 · 467 阅读 · 0 评论 -
最大流模板
#include #include #include using namespace std; #define NN 305 #define INF 1<<30 #define CLR(arr,v) memset(arr,v,sizeof(arr)) template class MaxFlow{ public: void Clear(){ pos = head = total = 0;原创 2012-04-18 17:15:16 · 602 阅读 · 0 评论 -
最大流模版
const int inf = 0xfffffff; #define clr(arr,v) memset(arr,v,sizeof(arr)) template class MaxFlow{ public: int GetMaxFlow(int s,int t,int n) //n表示有n个点,s为源点,t为汇点 { int maxflow = 0,minflow = inf,cur原创 2012-10-02 10:19:09 · 522 阅读 · 0 评论 -
最小费用最大流模板
#include #include #include #include using namespace std; #define CLR(arr,v) memset(arr,v,sizeof(arr)) const int INF = 1<<29 ; template class MinCostMaxFlow{ public: void Clear(){ pos = 0; CLR(h原创 2012-04-25 15:54:05 · 678 阅读 · 0 评论
分享