随笔分类 - DP:图上dp(树和有向无环图)
摘要:给定一颗树形的网络 叶子结点为汇点 根节点为源点 求最大流量 换根dp: 适用于对于每一个点都要作为根进行一遍dp的题目 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <c
阅读全文
摘要:给定一个有向无环图,询问每个点可以到达点的数目. void toposort() { for(rint i=1;i<=n;i++) if(!deg[i]) q.push(i); while(!q.empty()) { int x=q.front(); q.pop(); f[x].set(x,1);
阅读全文