随笔分类 - 图论-宽搜(最短路BFS)
摘要:Christmas 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
阅读全文
摘要:大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为。因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多。但seeyou的手中只有两个杯子,它们的容量分别是N 毫升和M 毫升 可乐的体积为S (S include
阅读全文
摘要:题目描述 我们定义一个圆 C 为以原点 (0, 0) 为中心的单位圆(半径为 1 的圆)。给定在 C 圆周上相异的两点 A, B。请问由 A 出发,沿着圆周走到 B,是顺时针走比较近,还是逆时针走比较近呢? C 的圆周上的所有点都可以用 (cos(t), sin(t)) 来表示,其中 t 的物理意义
阅读全文
摘要:Olya loves energy drinks. She loves them so much that her room is full of empty cans from energy drinks. Formally, her room can be represented as a fi
阅读全文
摘要:http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=682&pid=1003 中文题意,不再描述。 题解: 顺序给山峰出现的时间,明显地用二分来查找。然后连通块用并查集(也可以BFS,复杂度都是O(n))来维护。 1
阅读全文
摘要:You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock.
阅读全文
摘要:Now an emergent task for you is to open a password lock. The password is consisted of four digits. Each digit is numbered from 1 to 9. Each time, you
阅读全文
摘要:Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You m
阅读全文
摘要:The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room
阅读全文
摘要:Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a numb
阅读全文
摘要:Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and
阅读全文
摘要:宽度优先搜索(BFS,Breadth-First Search)也是搜索的手段之一,与深度优先搜索类似,从某个状态出发搜索所有可以到达的状态。 与深度优先搜索的不同之处在于搜索的顺序,宽度优先搜索总是先搜索距离初始状态最近的状态。也就是说,它是按照开始状态→只需一次转移就能到达的所有状态→只需2次就
阅读全文