摘要: 水题 练习一下堆栈和队列的使用 阅读全文
posted @ 2017-08-09 22:39 GGBeng 阅读(460) 评论(0) 推荐(0) 编辑
摘要: 一、深入理解DFS 采用递归写法 深度优先,思路就是沿着一条路一直走,直到走到死胡同,原路返回,返回到有多条道路的地方换其他路走。直到这条支路全部都访问过了,按照原路返回,回到起点,如果起点还有别的支路,那么继续访问,反之结束整个搜索过程。 实际解题的时候不可能无所约束的搜索下去,原因之一是会超时( 阅读全文
posted @ 2017-08-09 19:13 GGBeng 阅读(461) 评论(0) 推荐(0) 编辑
摘要: 一、题目回顾 题目链接:zxa and leaf Sample Input 2 3 2 1 2 1 3 2 4 3 9 6 2 1 2 1 3 1 4 2 5 2 6 3 6 5 9 Sample Output 3 1 Hint If you need a larger stack size, pl 阅读全文
posted @ 2017-08-09 01:27 GGBeng 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 一、题目回顾 题目链接:Alyona and a tree Examples Input 52 5 1 4 61 71 13 53 6 Output 1 0 1 0 0 Input 59 7 8 6 51 12 13 14 1 Output 4 3 2 1 0 Note In the example 阅读全文
posted @ 2017-08-09 01:20 GGBeng 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 一、题目回顾 题目链接:Prime Ring Problem Problem Description A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circl 阅读全文
posted @ 2017-08-09 01:12 GGBeng 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 一、题目回顾 题目链接:Anti-prime Sequences Sample Input 1 10 2 1 10 3 1 10 5 40 60 7 0 0 0 Sample Output 1,3,5,4,2,6,9,7,8,10 1,3,5,4,6,2,10,8,7,9 No anti-prime 阅读全文
posted @ 2017-08-09 01:01 GGBeng 阅读(218) 评论(0) 推荐(0) 编辑