摘要: 这一题是典型的欧拉道路题目。 欧拉道路的定义是: 除了起点和终点外, 其他点的“进出” 次数应该相等。 换句话说,除了起点和终点外, 其他点的度数应该是偶数。对于有向图, 则必须其中一个点的出度恰好比入度大1, 另一个的入度比出度大。如果奇点数不存在的话, 则可以从... 阅读全文
posted @ 2018-04-30 11:34 MCQ 阅读(274) 评论(3) 推荐(0) 编辑
摘要: 什么是欧拉路径?在图上用一种走法经过所有的边一次且只有一次的路径叫做欧拉路径。即一笔画。如果这条路径的起点和终点重合,那么就是欧拉回路。如何判断图是否有欧拉回路或者欧拉路径?无向图:因为欧拉路径中,除了起点与终点以外,任意点的“进”“出”次数相等,所以除了两个点为奇点... 阅读全文
posted @ 2018-04-30 10:01 MCQ 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 拓扑排序水题,但因为没做好邻接阵的初始化导致WA了几发,以后一定要注意初始化!!!#includeusing namespace std;#define maxn 1000vector G[maxn];int in[maxn]; //入度int t... 阅读全文
posted @ 2018-04-30 09:07 MCQ 阅读(104) 评论(0) 推荐(0) 编辑
摘要: /*==================================================*\ | topoSort -- 使用dfs | 使用dfs难以保证topo结果为最小的顺序 \*========================... 阅读全文
posted @ 2018-04-30 00:28 MCQ 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 拓扑排序+并查集/*#includeusing namespace std;*/#include #include #include#include #include using namespace std;#define maxn 10005int pre[1000... 阅读全文
posted @ 2018-04-30 00:26 MCQ 阅读(89) 评论(0) 推荐(0) 编辑
摘要: /*==================================================*\| topoSort -- 使用dfs | 使用dfs难以保证topo结果为最小的顺序\*=================================... 阅读全文
posted @ 2018-04-29 15:10 MCQ 阅读(79) 评论(0) 推荐(0) 编辑
摘要: 最小生成树水题#includeusing namespace std;#define inf 0x3f3f3f3f#define M 105int mat[M][M];int prim(int n,int sta)//n表示有n个顶点,sta表从sta这个顶点出发生成... 阅读全文
posted @ 2018-04-28 00:55 MCQ 阅读(86) 评论(0) 推荐(0) 编辑
摘要: 并查集水题,一开始超时了,把cin换成scanf就AC了#include #include#include#include#includeusing namespace std;int pre[10000005];int m[10000000];int Find(in... 阅读全文
posted @ 2018-04-28 00:41 MCQ 阅读(82) 评论(0) 推荐(0) 编辑
摘要: dfs+查过的做记号/*ample Input1 1*3 5*@*@***@***@*@*1 8@@****@*5 5****@*@@*@*@**@@@@*@@@**@0 0Sample Output0122 */#include #includeusing name... 阅读全文
posted @ 2018-04-26 00:35 MCQ 阅读(70) 评论(0) 推荐(0) 编辑
摘要: prim算法:int prim(int n,int sta)//n表示有n个顶点,sta表从sta这个顶点出发生成最小生成树{ int mark[M],dis[M]; int i,j,sum = 0,flag; //sum是总的最小生成树边权值 ... 阅读全文
posted @ 2018-04-25 19:10 MCQ 阅读(132) 评论(0) 推荐(0) 编辑