摘要: 学到了cin.get()清除输入流的换行符和getline(cin,s)获取一行的输入。#includeusing namespace std;int main(){ int t; cin>>t; cin.get(); while(t--) ... 阅读全文
posted @ 2018-04-30 14:09 MCQ 阅读(78) 评论(0) 推荐(0) 编辑
摘要: prim算法(不用并查集)#includeusing namespace std;#define inf 0x3f3f3f3f#define M 105//int mat[M][M];/*int pre[M];int Find(int x){ int p,t; ... 阅读全文
posted @ 2018-04-30 13:34 MCQ 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 这一题是典型的欧拉道路题目。 欧拉道路的定义是: 除了起点和终点外, 其他点的“进出” 次数应该相等。 换句话说,除了起点和终点外, 其他点的度数应该是偶数。对于有向图, 则必须其中一个点的出度恰好比入度大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) 编辑