![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
拓扑排序
Dilly__dally
这个作者很懒,什么都没留下…
展开
-
紫书UVA 10305
拓扑排序水题,但因为没做好邻接阵的初始化导致WA了几发,以后一定要注意初始化!!!#include<bits/stdc++.h>using namespace std;#define maxn 1000vector<int> G[maxn];int in[maxn]; //入度int topo[maxn], t,n,m;void init(...原创 2018-04-30 09:07:23 · 134 阅读 · 0 评论 -
拓扑排序模板
/*==================================================*\| topoSort -- 使用dfs | 使用dfs难以保证topo结果为最小的顺序\*==================================================*/int n, m, a, b, G[maxn][maxn]; int c[maxn...原创 2018-04-29 15:09:52 · 111 阅读 · 0 评论 -
HDU 1181
拓扑排序+并查集/*#include<bits/stdc++.h>using namespace std;*/#include <stdio.h>#include <string.h>#include<iostream>#include <vector>#include <queue>using namespac...原创 2018-04-30 00:25:37 · 251 阅读 · 0 评论 -
UVA 124(求所有的拓扑序+字符串按行读入)
题意:第一行给定变量,第二行给定给定约束,每个约束包含两个变量, x y表示x<y思路:DFS割边法求拓扑排序,每一次DFS完要记得还原现场。注意:此题要按行读入,学习到了用getline(cin,s)按行读入 //s为string对象 ,然后用 istringstream is(s),while(is>>ch) ……#include<bits/stdc+...原创 2018-08-06 21:45:02 · 552 阅读 · 0 评论 -
POJ1094(拓扑排序判定有环、不能确定、能确定)
#include<stdio.h>#include<string.h>int map[27][27],indegree[27],q[27];int TopoSort(int n) //拓扑排序{ int c=0,temp[27],loc,m,flag=1,i,j; ////flag=1:有序 flag=-1:不确定 for(i=1;i<...原创 2018-08-07 22:18:26 · 125 阅读 · 0 评论