cunzai_zsy0531

关注我
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 15 下一页
摘要: 题面 循环同构的话很容易想到把串延长一倍,跑的时候找所有长度为 \(n\) 的公共子串的出现次数即可。 点击查看代码 const int N=3e6+13; char s[N<<1]; int nxt[N<<1],len[N<<1],ptot=1,lastpos=1,cnt[N<<1]; std:: 阅读全文
posted @ 2022-05-18 21:13 cunzai_zsy0531 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 题面 对 \(T\) 建 SAM,拿 \(S\) 进去跑,可以得到每个 \(S\) 的前缀 \(S_i\) 的最长匹配后缀长度 \(sl_i\)。那么对于一个询问 \([l,r]\),答案就是 \(\max_{l\leq i\leq r}\{\min(sl_i,i-l+1)\}\)。 里面这个 \( 阅读全文
posted @ 2022-05-18 21:08 cunzai_zsy0531 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 题面 本质不同第 \(k\) 小。对 SAM 上每个点求一个 \(b_i\) 表示从这个点开始往后走能走到的本质不同的子串个数。然后拿 \(k\) 在自动机上跑即可。 点击查看代码 const int N=9e4+13; char s[N]; int nxt[N<<1],len[N<<1],ptot 阅读全文
posted @ 2022-05-18 21:07 cunzai_zsy0531 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 题面 拿出出现次数为 \(k\) 的点,给这个点表示的长度区间 \(+1\),这个可以使用差分解决。 点击查看代码 const int N=1e5+13; char s[N]; int nxt[N<<1],len[N<<1],ptot,lastpos,ind[N<<1]; ll cnt[N<<1], 阅读全文
posted @ 2022-05-18 21:01 cunzai_zsy0531 阅读(46) 评论(0) 推荐(0) 编辑
摘要: 题面 给一个串建 SAM,另一个串在上面跑。 点击查看代码 const int N=2.5e5+13; char s[N],t[N]; int nxt[N<<1],len[N<<1],ptot=1,lastpos=1; std::unordered_map<int,int> son[N<<1],bo 阅读全文
posted @ 2022-05-18 20:48 cunzai_zsy0531 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 题面 每个点 \(u\) 代表 \(len_ u-len_{nxt_u}\) 这么多串。这个也可以 DAWG dp 求得,不过太麻烦了。 点击查看代码 const int N=1e5+13; int n,nxt[N<<1],len[N<<1],lastpos=1,ptot=1; char s[N]; 阅读全文
posted @ 2022-05-18 20:46 cunzai_zsy0531 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 题面 拆出来的点贡献为 \(0\),其他贡献为 \(1\),在 DAWG 上统计一个后缀和即可。 点击查看代码 const int N=1e6+13,M=26; int n,len[N<<1],nxt[N<<1],ptot=1,lastpos=1,ind[N<<1]; ll cnt[N<<1]; s 阅读全文
posted @ 2022-05-18 20:41 cunzai_zsy0531 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 题面 当年见这题的时候还是初三的年轻选手。现在已经是老选手了…… 考虑推式子: \[ \begin{aligned} &\ \ \ \ \ \sum_T (\sum_{i=1}^{n-1}w_{e_i})\times\gcd_{i=1}^{n-1}w_{e_i}\\ &=\sum_T \big(\s 阅读全文
posted @ 2022-05-18 20:35 cunzai_zsy0531 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 题面 板子。注意模数不是质数的 \(\det\): inline int det(int n){ int res=1;bool flag=0; for(int i=1;i<=n;++i) for(int j=i+1;j<=n;++j){ while(a[i][i]){ int tmp=a[j][i] 阅读全文
posted @ 2022-05-18 20:31 cunzai_zsy0531 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 题面 这题挺有意思的。平常的矩阵树定理求的是 \[ \sum_T\prod_{e\in T}w_e \] 这题要求 \[ \begin{aligned} \sum_T\prod_{e\in T}p_e\prod_{e\not\in T}(1-p_e) &=\sum_T(\prod_{e\in T}p 阅读全文
posted @ 2022-05-18 20:29 cunzai_zsy0531 阅读(13) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 15 下一页