摘要:
F - Mr. Panda and Fantastic Beasts 参考:[acm/icpc2016ChinaFinal][CodeforcesGym101194] Mr. Panda and Fantastic Beasts 后缀自动机 把2~n的串用一个特殊字符串起来,然后对这个新串建后缀自动 阅读全文
摘要:
求 n 以内的素数和以及素数个数 复杂度:\(O(n^{\frac{3}{4}})\) // Created by CAD #include <bits/stdc++.h> #define ll long long using namespace std; ll check(ll v,ll n,ll 阅读全文
摘要:
后缀自动机 // Created by CAD #include <bits/stdc++.h> using namespace std; const int maxn=1e6+5; namespace sam{ int len[maxn<<1],link[maxn<<1],Next[maxn<<1 阅读全文
摘要:
SP1811 LCS - Longest Common Substring 用 sam 进行字符串匹配,建 s 的 sam,然后用 t 在 s 的 sam 上进行匹配,匹配过程中,沿着 Next 转移往下走,如果失配,则沿着 link 链接往上跳,因为 link 链接是该节点的后缀,所以这样跳就不会 阅读全文