上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 109 下一页

2015年6月1日

判断无向图是否有环路的方法 -并查集 -BFS

摘要: 可以利用并查集或者带颜色标记的BFS(来自算法导论)判断。 首先介绍第一种,用并查集来判断: 首先初始化所有元素的根为-1,-1代表根节点,接下来对于图中的每一条边(v1,v2)都并入集合,并入的方式为查找v1和v2的根节点,然后让v2的根节点作为v1的根节点,查找根节点的过程为:如果当前的结点... 阅读全文

posted @ 2015-06-01 16:14 张大大123 阅读(2406) 评论(0) 推荐(0) 编辑

1021. Deepest Root (25) -并查集判树 -BFS求深度

摘要: 题目如下: A graph which is connected and acyclic can be considered a tree. The height of the tree depends on the selected root. Now you are supposed t... 阅读全文

posted @ 2015-06-01 15:01 张大大123 阅读(294) 评论(0) 推荐(0) 编辑

2015年5月31日

百度地图API的学习

摘要: 我们可以进入百度API的网站学习百度地图API:http://dev.baidu.com/wiki/map/index.php,看完这些你应该基本上会掌握了,还有一些显示地图中一些很神奇的效果,需要一些别人写好的类库,我们可以查看学习,并下载其API源代码:http://dev.baidu.co... 阅读全文

posted @ 2015-05-31 09:25 张大大123 阅读(244) 评论(0) 推荐(0) 编辑

2015年5月30日

1022. Digital Library (30) -map -字符串处理

摘要: 题目如下: A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and publish... 阅读全文

posted @ 2015-05-30 13:58 张大大123 阅读(152) 评论(0) 推荐(0) 编辑

1020. Tree Traversals (25) -BFS

摘要: 题目如下: Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supp... 阅读全文

posted @ 2015-05-30 13:44 张大大123 阅读(142) 评论(0) 推荐(0) 编辑

2015年5月29日

利用Dijkstra算法实现记录每个结点的所有最短路径

摘要: 最近在做PAT时发现图论的一些题目需要对多条最短路径进行筛选,一个直接的解决办法是在发现最短路径的时候就进行判断,选出是否更换路径;另一个通用的方法是先把所有的最短路径记录下来,然后逐个判断。前者具有一定的难度并且不好排查BUG,因此我设计了一种基于Dijkstra的记录所有最短路的简捷算法,用... 阅读全文

posted @ 2015-05-29 13:16 张大大123 阅读(1384) 评论(0) 推荐(0) 编辑

2015年5月28日

CSS House

摘要: CSS House (3D Border Demo 2) by Chris Hester ... 阅读全文

posted @ 2015-05-28 11:56 张大大123 阅读(107) 评论(0) 推荐(0) 编辑

2015年5月27日

1017. Queueing at Bank (25) - priority_queuet

摘要: 题目如下: Suppose a bank has K windows open for service. There is a yellow line in front of the windows which devides the waiting area into two parts. A... 阅读全文

posted @ 2015-05-27 19:16 张大大123 阅读(187) 评论(0) 推荐(0) 编辑

2015年5月26日

1016. Phone Bills (25) -vector排序(sort函数)

摘要: 题目如下: A long-distance telephone company charges its customers by the following rules: Making a long-distance call costs a certain amount per minut... 阅读全文

posted @ 2015-05-26 17:06 张大大123 阅读(139) 评论(0) 推荐(0) 编辑

2015年5月25日

1015. Reversible Primes (20)

摘要: 题目如下: A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73... 阅读全文

posted @ 2015-05-25 13:38 张大大123 阅读(110) 评论(0) 推荐(0) 编辑

上一页 1 ··· 29 30 31 32 33 34 35 36 37 ··· 109 下一页

导航