删除边的操作不容易实现一般就是先离线然后逆序来做。逆序就变成了合并,用并存集判断连通,用Treap树来维护一个连通分量里的名次。Treap = Tree + Heap。就是用一个随机的优先级来平衡树。名次查询需要维护树的结点数量,假设当前在u点,u的左子树有n个结点,那么u的就是以u为根的树上第n+...
分类:
其他好文 时间:
2015-09-13 18:40:42
阅读次数:
221
Problem:Givennnodes labeled from0ton - 1and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these edges m...
分类:
其他好文 时间:
2015-09-12 06:21:54
阅读次数:
428
记忆化递归搜索,注意树的规模可能会很大(2m),用64位整数也需要边计算边取模以防止溢出。http://acm.hdu.edu.cn/showproblem.php?pid=5401 1 #include 2 #include 3 #include 4 #include 5 6 using...
分类:
其他好文 时间:
2015-09-11 20:42:09
阅读次数:
146
题目连接http://acm.hdu.edu.cn/showproblem.php?pid=3549Flow ProblemDescriptionNetwork flow is a well-known difficult problem for ACMers. Given a graph, you...
分类:
其他好文 时间:
2015-09-08 21:53:08
阅读次数:
152
From:http://www.jbxue.com/LINUXjishu/14582.html查看CPU信息(型号) :# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c 8 Intel(R) Xeon(R) CPU ...
分类:
系统相关 时间:
2015-09-08 15:29:04
阅读次数:
170
Vbs脚本实现数据CUT备份及自动轮询删除备份数据我们上一篇文章中介绍了使用vbs脚本不同版本的office激活任务,其实说到vbs脚本相信大家都很了解了,有什么作用呢,其实说白了就是执行批处理任务的工具。Vbs在windows上应用相对比较多,其功能上我们就不多说了,今天呢还是介绍v..
分类:
其他好文 时间:
2015-09-07 07:12:15
阅读次数:
256
Graph Valid TreeGivennnodes labeled from0ton - 1and a list of undirected edges (each edge is a pair of nodes), write a function to check whether these...
分类:
其他好文 时间:
2015-09-06 12:31:51
阅读次数:
169
poj 3017 Cut the Sequence单调队列题意是:把一个 长度 为 n 的 数列 分成任意份,使每一份的和不超过m,求每一份的最大值的和,使和最小动态规划方程 是 f [i] = f[j] + max{ f[j+1] , f[j+2] , f[i] };朴素的算法是 O(n^2);用...
分类:
其他好文 时间:
2015-09-05 22:13:04
阅读次数:
277
给一个n个节点n条边的无向图G,试判断图中是否存在哈密顿路径。若G中存在哈密顿路径l,则路径端点度数不小于1,其余点度数不小于2。则G存在哈密顿路径的必要条件:1)G连通;2)G中度数为1的点不超过两个。考虑到简单连通图中边的数目m不超过n,1)若 m = n - 1,则可从任一度数为1的点搜索即可...
分类:
其他好文 时间:
2015-09-05 20:51:44
阅读次数:
234