上一页 1 ··· 43 44 45 46 47 48 49 50 51 ··· 54 下一页
  2022年10月25日
摘要: 残量网络: 由 剩余容量边和反向平衡流量 的边构成 dinic算法(省去了建图与s,t) 复杂度 O(n^2 *m) const int N =1e6+4, M =5*N ; const int inf =1e15+7; int all=1,hd[N],go[M],w[M],nxt[M]; int 阅读全文
posted @ 2022-10-25 23:31 towboat 阅读(24) 评论(0) 推荐(0)
摘要: floy 找圈 #include <iostream> #include <vector> #include <map> #include <cstring> using namespace std; const int N=300; int a[N][N],vis[N],n,m; int tot; 阅读全文
posted @ 2022-10-25 22:53 towboat 阅读(25) 评论(0) 推荐(0)
摘要: 求图上苗条度(最大边 - 最小边) 最小的生成树 像kruskal 一样,给边排序,枚举L,R 区间,更新答案 #include <iostream> #include <cstring> #include <algorithm> using namespace std ; const int M= 阅读全文
posted @ 2022-10-25 21:20 towboat 阅读(15) 评论(0) 推荐(0)
摘要: kmp+字典树 #include <iostream> #include <cstring> #include <queue> using namespace std ; const int N=1e4+2,M=1e6+2; char s[M]; int val[N]; int ch[N][30], 阅读全文
posted @ 2022-10-25 18:22 towboat 阅读(24) 评论(0) 推荐(0)
摘要: 找字符串的最短循环节 1. kmp #include <bits/stdc++.h> using namespace std ; const int N=1e6+1; char a[N]; int n,p[N]; void init(){ int i,j=0; for(i=1;i<n;i++){ w 阅读全文
posted @ 2022-10-25 13:47 towboat 阅读(27) 评论(0) 推荐(0)
摘要: 一个字符串,它是由某个字符串不断自我连接形成的。但是这个字符串是不确定的,现在只想知道它的最短长度是多少。 #include <iostream> using namespace std ; const int N=1e6+1; char a[N]; int n,p[N]; void init(){ 阅读全文
posted @ 2022-10-25 13:44 towboat 阅读(23) 评论(0) 推荐(0)
摘要: 关于字符串匹配问题 比如A,B串,现在要在A中找B 扫描A串,并更新能匹配到B的什么位置 关于kmp算法如何工作,有经典说法 神犇解说 摘选 我们用两个指针i和j分别表示,A[i-j+ 1..i]与B[1..j]完全相等。也就是说,i是不断增加的,随着i的增加j相应地变化,且j满足以A[i]结尾的长 阅读全文
posted @ 2022-10-25 00:52 towboat 阅读(20) 评论(0) 推荐(0)
  2022年10月24日
摘要: 给一个串和一个字典(一些字符串) 将这个串分解为字典单词的连接(如 abcd = ab+cd =a+bcd ) 问有多少方案 线性dp 枚举位置 i f[i] += f[j] i<j , string(i,j) 为字典单词 直接枚举 j 和单词 明显超时 用到字典树,从 位置 i 开始在字典树上找单 阅读全文
posted @ 2022-10-24 18:49 towboat 阅读(26) 评论(0) 推荐(0)
摘要: A,B 打牌(牌的数量为偶数), 计算A赢 B赢 平局的方案数 如果A赢 1.A获得最大的牌, 2.A没有最大的牌,但如果有 n-1 的牌,逼B交n的牌,也可能赢, >>>>> f[n][0]= c(n-1,n/2-1) +f[n-2][1] #include <iostream> using na 阅读全文
posted @ 2022-10-24 11:20 towboat 阅读(20) 评论(0) 推荐(0)
  2022年10月23日
摘要: 给一个序列划分为若干组,每组的和 S>=0, 问方案数 首先是暴力dp for(i=1;i<=n;i++) cin>>a[i],s[i]=s[i-1]+a[i]; f[0]=1; for(i=1;i<=n;i++) for(j=0;j<i;j++) if(s[i]>=s[j]) f[i]+=f[j] 阅读全文
posted @ 2022-10-23 23:42 towboat 阅读(13) 评论(0) 推荐(0)
上一页 1 ··· 43 44 45 46 47 48 49 50 51 ··· 54 下一页