2012年8月13日

网络流Dinic模板

摘要: 1 #define INF 2000000000 2 #define typec int//type of cost 3 const int pN=600000,eN=3000000; 4 struct Edge{ 5 int u,v,next; 6 typec w; 7 }; 8 Edge edge[eN]; 9 int en,head[pN],cur[pN],ps[pN],dep[pN];10 void insert(int u,int v,typec w){11 edge[en].u=u;12 edge[en].v=v;13 edge[en].w... 阅读全文

posted @ 2012-08-13 20:57 acoderworld 阅读(73) 评论(0) 推荐(0)

【转】最小树形图 模版--朱刘算法

摘要: 1 #define INF 0x7fffffff 2 #define MAXN 1005 3 typedef __int64 type; 4 struct node 5 { 6 int u, v; 7 type w; 8 }edge[MAXN * MAXN]; 9 int pre[MAXN],id[MAXN],vis[MAXN],n,m,pos;10 type in[MAXN];11 type Directed_MST(int root, int V, int E)12 {13 int i;14 type ret = 0;15 while(true)1... 阅读全文

posted @ 2012-08-13 11:42 acoderworld 阅读(67) 评论(0) 推荐(0)

2012年8月12日

【转】最小树形图

摘要: 对于最小树形图前几天做了n个不定根的最小树形图,因为n<16对此我用的是dp方法WS过去了那道题目,0.3s相对于最小树形图的正确解法的0.001实在是惭愧,为此也找到了一种最小树形图的DP解法当然n<16时间和空间上才能受得了。再谈朱刘算法解决最小树形图问题:下面是转载的资料:有固定根的最小树形图求法O(VE):首先消除自环,显然自环不在最小树形图中。然后判定是否存在最小树形图,以根为起点DFS一遍即可。之后进行以下步骤。设cost为最小树形图总权值。0.置cost=0。1.求最短弧集合Ao(一条弧就是一条有向边)除源点外,为所有其他节点Vi,找到一条以Vi为终点的边,把它加入到 阅读全文

posted @ 2012-08-12 16:31 acoderworld 阅读(136) 评论(0) 推荐(0)

HDU 3177

摘要: Crixalis's EquipmentTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1419Accepted Submission(s): 578Problem DescriptionCrixalis - Sand King used to be a giant scorpion(蝎子) in the deserts of Kalimdor. Though he's a guardian of Lich King now, 阅读全文

posted @ 2012-08-12 16:00 acoderworld 阅读(47) 评论(0) 推荐(0)

导航