海上月是天上月,眼前人是心上人。
01 2022 档案
摘要:Solution 考虑把一个豆豆看成一条边,那限制流量为1,费用为1,豆豆即会被吃一次。拆点,两点之间连一条有贡献的边和无贡献的边,可做到让两条路径重合后不会多产生贡献。路线不可以相交可以通过连边的方式解决,但我们发现边数太多了。考虑我们连的一些无用的边,形如一个钝角三角形,明显有边
阅读全文
摘要:Solution 这是一道一个人覆盖一个区间的问题,对于人,考虑把他看成一流量,对于a_i的限制,相当于把a_i的流量放在了i点上,所以S和1号点连inf,n + 1号点和T连inf,i和i + 1连inf - a_i。对于留下的流量一定要产生
阅读全文
摘要:#include <cstdio> #include <iostream> #define LL long long #define RE register #define IN inline using namespace std; const int N = 5e5 + 5; int h[N <
阅读全文
摘要:#include<cstdio> #include<algorithm> using namespace std; const int N = 1e5 + 5; int dfn[N],low[N],dfc,f[N],g[N],n,m,K,L,cnt,tot,h[N]; struct edge{ in
阅读全文
摘要:\text{Solution} 一道简单的tarjan求割点,只需判断B点是否在子树内即可。 \text{Code} #include<cstdio> #include<algorithm> #define RE register #define IN inline using na
阅读全文
摘要:#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int t,S,T,n,a[55],b[55],cur[105],tot,h[105],dep[105],q[110]; struct edge{
阅读全文
摘要:#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int tot,n,t,dep[600],q[600],cur[600],h[600],S,T; struct edge{ int to,nxt,z
阅读全文
摘要:#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int h[705],cur[705],n,m,dep[705],q[705],tot = 1,S,T; struct edge{ int to,n
阅读全文
摘要:#include<cstdio> #include<algorithm> using namespace std; int a[5005],f[5005][5005],n,vis[5005][5005]; double slope(int x,int y) {return (a[x] - a[y])
阅读全文
摘要:Solution 考虑1和2相邻是必须要长度为1的篱笆,所以只需考虑1,2和0之间要不要放篱笆,用S连向所有的1,所有的2连向T,现在问题是要使S与T不连通,这不是经典的最小割问题吗? Code #include<cstdio> #incl
阅读全文
摘要:#include<cstdio> using namespace std; const int N = 1e5 + 5; int n,m,rt[N],sum[N << 5],ls[N << 5],rs[N << 5],size; void update(int &p1,int p2,int l,in
阅读全文
摘要:#include<cstdio> #define LL long long using namespace std; int n,a[100005]; LL ans = 0; int main() { scanf("%d",&n); for (int i = 1; i <= n; i++) scan
阅读全文
摘要:Solution 一个较为模板的最小割,对于第二问,把图的流量变为1,再跑一边网络流即可 Code #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int h[50],cur[
阅读全文
摘要:Solution 把木板看成一个点,把 看成一条边,因为一个 最多对应两块木板,现在问题转化成了二分图上的最小点覆盖问题,众所周知二分图上最小点覆盖等于最大匹配 Code #include<cstdio> #include<cstring> #include<algorithm>
阅读全文
摘要:Solution 先二分答案,考虑去求ans的排名,那么相当于去求有多少和是小于ans,对原序列做前缀和,问题转化成了求所有的S_r - S_l < ans \implies S_l > Sr - ans枚举一个S_r把S_l加入线段树中即可。 Code #inc
阅读全文
摘要:Solution 如何去确定以个炸弹,可以用一行和一列i,j,那么就相当于行和列进行最匹配,对于一个**#能把行分成两部分,处理每行每列的每部分,如果交点不是x**那就可以匹配 总结:dinic一般时间复杂度为O(nm),跑二分图匹配为O(m\sqrt{n}) Code #i
阅读全文
摘要:Solution 考虑a_i的限制,设a_i = \prod {p_i^{k_i}},s_i = \sum{k_i} 对于条件,当且仅当a_j | a_i且s_i = s_j + 1,以s_i的奇偶分为两个集合,发现是一个二分图,b_i则为流量,而对于权值大于0的
阅读全文