随笔分类 - 图论
摘要:题意: 给定n个点的有向图问,问能不能找到若干个环,让所有点都在环中,且让权值最小,KM算法求最佳完美匹配,只不过是最小值,所以把边权变成负值,输出时将ans取负即可 这道题是在VJ上交的
阅读全文
摘要:#include using namespace std; const int maxn = 5e4 + 5; const int inf = 0x3f3f3f3f; int n, head[maxn], dis[maxn], cnt; struct node{ int to, w, next; } ed[maxn*4]; //数组开2*maxn超时,开大一点 inlin...
阅读全文
摘要:次小生成树模板,别忘了判定不存在最小生成树的情况
阅读全文
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 typedef long long ll; 9 const int maxn = 100 + 5; 10 const int inf = 0x3f3f3f3f; 11 int n, m, ans; 12 ...
阅读全文
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 6 typedef long long ll; 7 const int maxn = 1e5 + 5; 8 const int maxm = 5e5 + 5; 9 int dfn[maxn], low[maxn], head[maxn]; 10 ll an...
阅读全文