![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Acwing
自由的犇儿哥
这个作者很懒,什么都没留下…
展开
-
传递闭包模板
传递闭包模板 for (int k = 1; k <= n; k++) for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) { g[i][j] = g[i][j] | (g[i][k] & g[k][j]); }请特别注意,对kkk的循环位于三重循环的最外侧g[i][j] = g[i]原创 2021-03-31 20:10:15 · 153 阅读 · 0 评论 -
匈牙利算法模板
Acwing#include<iostream>#include<cstring>#include<cstdio>using namespace std;const int n = 510, M = 100100;int e[M], ne[M], h[n], idx;int n1, n2, m;int st[n];int match[n];bool find(int x){ for (int i = h[x]; ~i; i = ne[原创 2021-03-31 09:24:23 · 120 阅读 · 0 评论 -
树形背包DP
一道题目,两种解法背包问题一定要按照物品、背包容积、决策的顺序进行遍历。增加背包容积的解法#include <bits/stdc++.h>using namespace std;const int N = 310, M = N * 2;int h[N], ne[M], v[M], idx;int w[N];int dp[N][N];int n, m;void add(int a, int b){ ++idx;v[idx] = b;ne[idx] = h[a]原创 2021-02-21 22:14:53 · 176 阅读 · 0 评论 -
走廊泼水节
最小生成树问题题目链接题解链接解决这道题的思想体现了对Kruskal算法的深刻理解。每当我们从排序好的边的数组中取出一条边准备连接时,这条边一定比它两个端点所对应的联通图的边集合中最小的边还要小。。基于这样的思想我们就能够求解出这道题。这其中有一点需要注意的是,原题中所说的添加的新的边是并不存在的。这也就是说这条添加的边的长度是我们可以人为随意决定的#include<iostream>#include<map>#include<vector>#inc原创 2020-11-17 14:44:48 · 127 阅读 · 0 评论