题目链接 传送门:https://ac.nowcoder.com/acm/contest/76/F 思路: 题目的意思就是判断图的连通性可以用可达性矩阵来求,至于图的存储可以用邻接矩阵来储存,求出来可达性矩阵后判断下 a[1] [n] 是不是为零就好了,不为零的话说明从1(自己)到 n(teacher)是连通的,为零的话就说明不是连通的 代码: #include <bits/stdc++.h> using namespace std; ; int n, m, a[MAXN][MAXN]; in
题目链接: http://poj.org/problem?id=2513 http://bailian.openjudge.cn/practice/2513?lang=en_US Time Limit: 5000MS Memory Limit: 128000K Description You are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possi
题目链接: https://cn.vjudge.net/problem/POJ-1860 Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can be s
一.问题 1.问题描述: 有n个点(1...n),输入整数对(8,9),表示8,9点之间存在相互的连接关系. 动态连通性问题--编写一段程序过滤掉所以无意义的整数对,即为在不破坏图连通性的前提下,以最简单的方式表示图的连通性.2.实现方案:设计数据结构保存已经存在的整数对,并且用他们来判断新数对是否满足新相连关系.3.实例应用:网络连接问题,电子触电设计,社交网络关系等等 二.解决 1.定义问题--设计api public class UF//(类名大写) (构造方法) UN(int N