图论算法--------------------
000
RomanticChopin
这个作者很懒,什么都没留下…
展开
-
Codeup 问题 A: 第一题 (BFS 做法)
一切杀不死我的,都将使我强大! 题目网站: http://codeup.cn/problem.php?cid=100000620&pid=0 题目描述 该题的目的是要你统计图的连通分支数。 输入 每个输入文件包含若干行,每行两个整数i,j,表示节点i和j之间存在一条边。 输出 输出每个图的联通分支数。 样例输入 1 4 4 3 5 5 样例输出 ...原创 2018-09-04 20:50:27 · 349 阅读 · 0 评论 -
Codeup墓地 问题 B: 连通图 (BFS写法)
题目描述 给定一个无向图和其中的所有边,判断这个图是否所有顶点都是连通的。 输入 每组数据的第一行是两个整数 n 和 m(0<=n<=1000)。n 表示图的顶点数目,m 表示图中边的数目。如果 n 为 0 表示输入结束。随后有 m 行数据,每行有两个值 x 和 y(0<x, y <=n),表示顶点 x 和 y 相连,顶点的编号从 1 开始计算。输入不保证这些边是否...原创 2018-09-06 16:06:58 · 270 阅读 · 0 评论 -
PAT A级 1076 Forwards on Weibo (超详细BFS做法)
一切杀不死我的,都将使我强大! 1076 Forwards on Weibo(30 分) Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social ...原创 2018-09-04 18:54:18 · 182 阅读 · 0 评论 -
PTA 1034 Head of a Gang (图论写法)
One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be t...原创 2019-01-21 21:37:52 · 216 阅读 · 0 评论