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$的
阅读全文