
图论 - DFS
Floraqiu
有志者事竟成,破釜沉舟,百二秦关终属楚。
苦心人天不负,卧薪尝胆,三千越甲可吞吴。
展开
-
1/26 训练五 深度优先搜索(dfs)E .(dfs 减枝! 注意回溯!给两个数ab,输出不超过b的最大a的重排) Permute Digits
1/26 训练五 深度优先搜索(dfs)E .(dfs 减枝! 注意回溯!给两个数ab,输出不超过b的最大a的重排) Permute DigitsYou are given two positive integer numbers a and b. Permute (change order) of the digits of a to construct maximal numbe原创 2018-01-26 20:46:20 · 400 阅读 · 1 评论 -
【dfs】【树形贪心】 UVA1267 Network 【树上建基站,覆盖所有叶节点】
【dfs】【树形贪心】 UVA1267 Network 【树上建基站,覆盖所有叶节点】Consider a tree network with n nodes where the internal nodes correspond to servers and the terminal nodes correspond to clients. The nodes are numbered f...原创 2018-07-28 14:03:23 · 408 阅读 · 0 评论 -
【dfs】【枚举】Tragedy Words CSU - 2087 【摆放元音、辅音字母、L】
【dfs】Tragedy Words CSU - 2087 【摆放元音、辅音字母、L】As is known to all, Wells doesn’t have a good command of English. As a result, some unfamiliar words, which may cause sadness of Wells, is called tragedy ...原创 2018-07-29 09:09:13 · 293 阅读 · 0 评论 -
【dfs】【判环简单题】Robot Motion HDU - 1035 【给定走路地图,判断何时走出或何时走成环】
【dfs】【判环简单题】Robot Motion HDU - 1035 【给定走路地图,判断何时走出或何时走成环】A robot has been programmed to follow the instructions in its path. Instructions for the next direction the robot is to move are laid down ...原创 2018-07-29 09:08:52 · 219 阅读 · 0 评论 -
【迭代加深dfs】【bfs】Z‘s Coffee CSU - 2061 【三个杯子倒咖啡】
【迭代加深dfs】【bfs】Z‘s Coffee CSU - 2061 【三个杯子倒咖啡】迭代加深dfs不会写,挖个坑,日后补,这里用的bfsZ is crazy about coffee. One day he bought three cups of coffee. The first cup has a capacity of A ml, the second has B...原创 2018-07-29 09:07:36 · 448 阅读 · 0 评论 -
【二分】【dfs】【剪枝】Sticks HDU - 1455 【拼凑小木棍,变成多条一样长的,求最小可能的长度】
【dfs】【剪枝】Sticks HDU - 1455 【拼凑小木棍,变成多条一样长的,求最小可能的长度】George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the ori...原创 2018-07-29 09:04:44 · 895 阅读 · 0 评论 -
【dfs + 预处理 + 二分】 Wells的明星生活 CSU - 2112 (预处理 类似火灾梯形)
和很多人想的不同,Wells其实是很低调的。刚刚过了520和521,爱信不信,巨怂Wells和喜欢的小姐姐表白了!Wells那是相当相当低调——之后的约会也是。不过,这次Wells遇到麻烦了……Wells和小姐姐正在浪漫的约会呢,Wells猛然得到最新消息,有若干狗仔团队正闻讯蜂拥而来(Wells毕竟还是蛮很有名气的嘛)……Wells真是不理解现在这些人对八卦的渴望怎么那么大,连保...原创 2018-07-26 09:00:49 · 207 阅读 · 0 评论 -
【dfs】(经典样题) Prime Ring Problem HDU - 1016 【素数环】
【dfs】(经典样题)Prime Ring Problem HDU - 1016 【素数环】A ring is compose of n circles as shown in diagram. Put natural number 1, 2, …, n into each circle separately, and the sum of numbers in two adjacent c...原创 2018-07-28 14:42:23 · 212 阅读 · 0 评论 -
【dfs】N皇后问题 HDU - 2553
【dfs】N皇后问题 HDU - 2553在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上。 你的任务是,对于给定的N,求出有多少种合法的放置方法。 Input 共有若干行,每行一个正整数N≤10,表示棋盘和皇后的数量;如果N=0,表示结束。Output 共有若干行,每行一个正整数,表示对应输入...原创 2018-07-28 14:33:48 · 229 阅读 · 0 评论 -
【dfs】(样题,熟悉邻接表写法vector) 单源最大权路径 CSU - 1960 【从起点走,找一条路径,使权和最大】
【dfs】(样题,熟悉连接表写法vector) 单源最大权路径 CSU - 1960 【从起点走,找一条路径,使权和最大】有一棵由N个结点构成的树,每一条边上都有其对应的权值。现在给定起点,求从该点出发的一条路径(至少有一条边)使得这条路径上的权值之和最大,并输出这个最大值。Input 第一行一个正整数T,代表数据组数。每组数据第一行两个正整数n(2<=n<=10^5),s(...原创 2018-07-28 14:30:56 · 453 阅读 · 0 评论 -
【dfs】后序遍历 HihoCoder - 1049 【已知前序和中序遍历,求后序遍历】
前序遍历: PreOrder = T_Root + PreOrder(T的左子树)+ PreOrder(T的右子树) 中序遍历: InOrder = InOrder(T的左子树)+ T_Root + InOrder(T的右子树) 后序遍历: PostOrder = PostOrder(T的左子树)+ PostOrder(T的右子树)+ T_Root【dfs】后序遍历 HihoCoder -...原创 2018-07-28 14:21:04 · 321 阅读 · 0 评论