摘要:
#include<bits/stdc++.h> #define int long long using namespace std; const int N=200005; inline int read() { int X=0; bool flag=1; char ch=getchar(); wh 阅读全文
摘要:
#include<cstdio> #include<algorithm> #include<cstring> #include<cmath> //Accepted??? using namespace std; const int N=2e5+5; const int Maxchar=26; cha 阅读全文
摘要:
solution: 很容易想到用回文自动机做。manacher算法也可以,但是我们这里不考虑。 但是这道题直接做并不好做。我的第一个思路是分两种情况讨论: 左端点或右端点重合,那么枚举一个左右端点即可包含或者交叉,枚举第一个回文子串 [ l , r ] [l,r] [l,r],然后计算区间 [ l 阅读全文
摘要:
#include<bits/stdc++.h> using namespace std; const int N=1e6+5; const int mod=19930726; struct node{ int len,fail,ch[26],siz; friend bool operator <(n 阅读全文
摘要:
题目描述 给定一个长度为 n n n 的字符串 S S S,令 T i T_i Ti 表示它从第 i i i 个字符开始的后缀。求 ∑ 1 < = i < j < = n n l e n ( T i ) + l e n ( T j ) − 2 × l c p ( T i , T j 阅读全文
摘要:
个人认为是比较简单的 d p dp dp。 首先,状态不难想,可求状态有这些:位数,前导零,limit标记,余数,满足条件的数的和,满足条件的数的平方和等。 其次,注意编程的细节。然后这道题就搞定了。 数位 d p dp dp的时间复杂度很好分析,就是所有可能的状态数。一般状态数 s s s<=1e 阅读全文
摘要:
忘了博客地址了。 后续可能上升为总结。 代码比较复杂,细节很多,建议背下来。 【模板】AC自动机(简单版) 由势能分析可知,Query 部分时间复杂度是 O ( 2 ∗ l e n T ) O(2*lenT) O(2∗lenT) 统计 f a i l fail fail 答案部分是长度和,因为只统计 阅读全文
摘要:
https://blog.csdn.net/dyx404514/article/details/41831947 定义和KMP不一样,同时程序实现非常复杂。建议背下来。主要是利用 d p dp dp的思想。 时间复杂度证明:每个点只会被枚举一次。所以是 O ( n ) O(n) O(n)。 #inc 阅读全文
摘要:
https://blog.csdn.net/qq_43456058/article/details/94588721 这玩意和扩展KMP很像,都是利用了 d p dp dp和贪心的思想(选择最远覆盖距离)。同时利用了状态的相似性。然后类似于“镜面”的对称点转换,做到了 O ( n ) O(n) O( 阅读全文