随笔分类 - dfs+bfs
摘要:题目地址:http://poj.org/problem?id=2488Sample Input31 12 34 3Sample OutputScenario #1:A1Scenario #2:impossibleScenario #3:A1B3C1A2B4C2A3B1C3A4B2C4题目:给你一个p...
阅读全文
摘要:题目地址:http://poj.org/problem?id=3414PotsTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 12080Accepted: 5104Special JudgeDescriptionYou are giv...
阅读全文
摘要:题目地址:http://poj.org/problem?id=3126InputOne line with a positive number: the number of test cases (at most 100). Then for each test case, one line wit...
阅读全文
摘要:题目地址:http://poj.org/problem?id=3083Sample Input28 8#########......##.####.##.####.##.####.##.####.##...#..##S#E####9 5##########.#.#.#.#S.......E#.#.#...
阅读全文
摘要:The Settlers of CatanTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 1123Accepted: 732DescriptionWithin Settlers of Catan, the 1995 German ga...
阅读全文
摘要:B. Two Buttonstime limit per test : 2 secondsmemory limit per test :256 megabytesinput :standard inputoutput : standard outputVasya has found a strang...
阅读全文
摘要:滑雪Time Limit: 1000MSMemory Limit: 65536KTotal Submissions: 79519Accepted: 29581DescriptionMichael 喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你...
阅读全文
摘要://---基于邻接表的bfs #include #include #include #include #include #include using namespace std; struct node { int date; struct node *next; ...
阅读全文
摘要:#include #include #include #include #include #define N 100000+2using namespace std;//无根树转有根树算法/* 算法分析:所谓无根树,就是根节点任意的树。我们可以给它确定一个根节点。 我们可以假定认为某一个节点为根...
阅读全文
摘要:#1050 : 树中的最长路时间限制:10000ms单点时限:1000ms内存限制:256MB描述上回说到,小Ho得到了一棵二叉树玩具,这个玩具是由小球和木棍连接起来的,而在拆拼它的过程中,小Ho发现他不仅仅可以拼凑成一棵二叉树!还可以拼凑成一棵多叉树——好吧,其实就是更为平常的树而已。但是不管怎么...
阅读全文
摘要:两次DFS求树中的最长路。基于邻接矩阵:代码:#include #include #include #include #include #include using namespace std;bool map[10001][10001];int n;int tail;bool vis[1001];...
阅读全文
摘要:路线冲突问题题目描述给出一张地图,地图上有n个点,任意两点之间有且仅有一条路。点的编号从1到n。现在兵团A要从s1到e1,兵团B要从s2到e2,问两条路线是否会有交点,若有则输出交点个数,否出输出”success”。输入多组输入。对于每组输入。第一行输入n(1#include #include #i...
阅读全文
摘要:欧拉回路Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9797Accepted Submission(s): 3554Problem Descri...
阅读全文
摘要:图练习-BFS-从起点到目标点的最短步数Time Limit: 1000ms Memory limit: 65536K有疑问?点这里^_^题目描述在古老的魔兽传说中,有两个军团,一个叫天灾,一个叫近卫。在他们所在的地域,有n个隘口,编号为1..n,某些隘口之间是有通道连接的。其中近卫军团在1号隘口,...
阅读全文
摘要:数据结构实验之图论二:基于邻接表的广度优先搜索遍历Time Limit: 1000MS Memory limit: 65536K题目描述给定一个无向连通图,顶点编号从0到n-1,用广度优先搜索(BFS)遍历,输出从某个顶点出发的遍历序列。(同一个结点的同层邻接点,节点编号小的优先遍历)输入输入第一行...
阅读全文
摘要:走迷宫Time Limit: 1000MS Memory limit: 65536K题目描述一个由n * m 个格子组成的迷宫,起点是(1, 1), 终点是(n, m),每次可以向上下左右四个方向任意走一步,并且有些格子是不能走动,求从起点到终点经过每个格子至多一次的走法数。输入 第一行一个整数...
阅读全文
摘要:数据结构实验图论一:基于邻接矩阵的广度优先搜索遍历Time Limit: 1000MS Memory limit: 65536K题目描述给定一个无向连通图,顶点编号从0到n-1,用广度优先搜索(BFS)遍历,输出从某个顶点出发的遍历序列。(同一个结点的同层邻接点,节点编号小的优先遍历)输入输入第一行...
阅读全文
摘要:图的深度遍历Time Limit: 1000MS Memory limit: 65536K题目描述请定一个无向图,顶点编号从0到n-1,用深度优先搜索(DFS),遍历并输出。遍历时,先遍历节点编号小的。输入输入第一行为整数n(0 #include #include #include #include...
阅读全文
摘要:数据结构实验:连通分量个数Time Limit: 1000MS Memory limit: 65536K题目描述在无向图中,如果从顶点vi到顶点vj有路径,则称vi和vj连通。如果图中任意两个顶点之间都连通,则称该图为连通图,否则,称该图为非连通图,则其中的极大连通子图称为连通分量,这里所谓的极大是...
阅读全文
摘要:Catch That CowTime Limit: 2000MSMemory Limit: 65536KTotal Submissions: 48127Accepted: 15077DescriptionFarmer John has been informed of the location of...
阅读全文