03 2013 档案

欧拉回路的一点研究与Codeforces 62D Wormhouse
摘要:图G的一个回路,若它恰通过G中每条边一次,则称该回路为欧拉回路。具有欧拉回路的图称为欧拉图。欧拉回路就是从图上的一点出发,经过所有的边一次,最终回到起点的路径。首先是求出图中所有欧拉回路的朴素算法。深搜遍历所有的边,直到找到所有的欧拉回路。void dfs(int u,int deep) { ans[deep]=u;//将点u加入到路径中 if (deep==m)//若遍历了所有的边 { if (u==bg)//终点等于起点,即找到欧拉回路 { for (int i=0; i<=m; i++) ... 阅读全文

posted @ 2013-03-27 15:13 电子幼体 阅读(253) 评论(0) 推荐(0)

poj 3013 Big Christmas Tree 最短路
摘要:Big Christmas TreeTime Limit:3000MSMemory Limit:131072KTotal Submissions:18039Accepted:3811DescriptionChristmas is coming to KCM city. Suby the loyal civilian in KCM city is preparing a big neat Christmas tree. The simple structure of the tree is shown in right picture.The tree can be represented as 阅读全文

posted @ 2013-03-23 20:50 电子幼体 阅读(122) 评论(0) 推荐(0)

SPFA模板
摘要:#include <iostream> #include <cstdio> #include <cstring> #include <queue> using namespace std; const int maxn=155555; const int INF=-1; struct NODE { int to; long long w; int next; }link[maxn]; int edge,node,src,dest; long long dist[maxn]; int head[maxn]; bool visit[maxn]; in 阅读全文

posted @ 2013-03-23 20:35 电子幼体 阅读(125) 评论(0) 推荐(0)

强力开刷图论----目录(图论再临)
摘要:第一章、图Codeforces 246D. Colorful GraphCodeforces 24A. Ring roadCodeforces 25D. Roads not only in Berland 并查集1.3 图的遍历Codeforces 278C. Learning Languages 图的遍历Codeforces 103B. Cthulhu 寻找奈亚子Codeforces 217A. Ice Skating 搜索Codeforces 263 D. Cycle in Graph 环Codeforces 107A. Dorm Water Supply 搜图Codeforces 117 阅读全文

posted @ 2013-03-21 15:50 电子幼体 阅读(238) 评论(0) 推荐(0)

[置顶] 强力开刷图论----目录(不定期更新)
摘要:第一章、图Codeforces 246D. Colorful GraphCodeforces 24A. Ring roadCodeforces 25D. Roads not only in Berland 并查集1.3 图的遍历Codeforces 278C. Learning Languages 图的遍历Codeforces 103B. Cthulhu 寻找奈亚子Codeforces 217A. Ice Skating 搜索Codeforces 263 D. Cycle in Graph 环Codeforces 107A. Dorm Water Supply 搜图Codeforces 117 阅读全文

posted @ 2013-03-21 15:50 电子幼体 阅读(221) 评论(0) 推荐(0)

poj 1182 食物链 并查集
摘要:食物链Time Limit:1000MSMemory Limit:10000KTotal Submissions:33327Accepted:9678Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述:第一种说法是"1 X Y",表示X和Y是同类。第二种说法是"2 X Y",表示X吃Y。此人对N个动物,用上述两种说法,一句接一句地说出K句话,这K句 阅读全文

posted @ 2013-03-17 17:34 电子幼体 阅读(182) 评论(0) 推荐(0)

hdu 1400 Mondriaan's Dream 状态压缩
摘要:Problem DescriptionSquares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, after producing the drawings in his 'toilet series' (where he had to use his toilet paper to draw on, for all of his paper was filled with squares and rectangles), he dreamt of filling a 阅读全文

posted @ 2013-03-17 15:18 电子幼体 阅读(150) 评论(0) 推荐(0)

较为复杂的动态规划整理
摘要:一、POJ 1191 棋盘分割化简均方差的公式后发现,均方差的平方=(1/n)*(n个矩形总分平方的和)-平均值的平方。f[k][x1][y1][x2][y2]表示将左上角坐标为(x1,y1)右下角坐标为(x2,y2)的矩形分割k次得到的总分平方和的最小值。s[x1][y1][x2][y2]表示矩形(x1,y1)(x2,y2)总分的平方。t1=min(f[k-1][x1][a][x2][y2]+s[x1][y1][x2][a-1], f[k-1][x1][y1][x2][a-1]+s[x1][a][x2][y2]);(y1+1<=a<=y2)//横向切割t2=min(f[k-1][ 阅读全文

posted @ 2013-03-08 18:21 电子幼体 阅读(134) 评论(0) 推荐(0)

导航