随笔分类 -  图论

摘要:题意: 给定n个点的有向图问,问能不能找到若干个环,让所有点都在环中,且让权值最小,KM算法求最佳完美匹配,只不过是最小值,所以把边权变成负值,输出时将ans取负即可 这道题是在VJ上交的 阅读全文
posted @ 2019-05-21 18:04 CoffeeCati 阅读(171) 评论(0) 推荐(0)
摘要:#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... 阅读全文
posted @ 2019-05-16 18:30 CoffeeCati 阅读(187) 评论(0) 推荐(0)
摘要:次小生成树模板,别忘了判定不存在最小生成树的情况 阅读全文
posted @ 2019-05-16 01:20 CoffeeCati 阅读(118) 评论(0) 推荐(0)
摘要: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 ... 阅读全文
posted @ 2019-05-10 17:44 CoffeeCati 阅读(120) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2019-05-10 13:33 CoffeeCati 阅读(190) 评论(0) 推荐(0)