为何scanf("%s", str)不需要&运算 经常忘掉的字符串知识点,最好不加&,不加&最标准,指针如果像scanf里一样加&是错的,大概是未定义行为 马拉车 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<queue> using…
后缀家族已知成员         后缀树         后缀数组         后缀自动机         后缀仙人掌         后缀预言         后缀Splay ? 后缀树是后缀数组和后缀自动机的祖先? 功能还是比较强大的,在回文串或者字典序方面还是有用处. 而且现在已经有了线性的建树方法. (但其实我也没用过后缀树.)下面对比后缀自动机和后缀数组     单个字符串问题                                                     …
题目: https://loj.ac/problem/6173 分析: 考虑枚举宽度w,然后把宽度压位集中,将它们哈希 (这是w=2的时候) 然后可以写一下string=“ac#bc” 然后就是求这个string本质不同的字符串个数(要去掉连接符#) 这个可以用后缀数组/后缀自动机解决 小技巧:每个连接符用不同的整数表示,那么去做height的时候就不会把连接符包含进去 后缀数组解决的时间复杂度:O(n^3logn)…
快补题别再摸鱼了(17/34) 1.AC自动机 #define maxnode 1000010 #define maxsize 26 struct ahocT{ int ch[maxnode][maxsize]; int e[maxnode],fail[maxnode]; int sz; void init(){ sz=;memset(ch[],,]));memset(e,,sizeof(e));return; } int idx(char c) {return c-'a';} void ins…
后缀数组: #include<cstdio> #include<algorithm> #include<cstring> #include<vector> using namespace std; typedef long long ll; ,mod=; char s[N]; ],Log[N]; void Sort(int* x,int* y,int m) { ; i<m; ++i)c[i]=; ; i<n; ++i)++c[x[i]]; ; i…
仰望半月的夜空 题解 可以的话,支持一下原作吧... 这道题数据很弱..... 因此各种乱搞估计都是能过的.... 算法一 暴力长度然后判断判断,复杂度\(O(n^3)\) 期望得分15分 算法二 通过二分+\(hash\)或者等等来优化字典序比较,复杂度\(O(n^2 \log n)\),可能要松一下 期望得分30分 ps:好吧有55分... 算法三 我们考虑字符集非常小的情况 我们猜想出题人很难卡掉玄学做法,因此我们就想一个玄学做法 我们考虑用\(SAM\)来处理这个问题 建出\(SAM\)…
SPOJ694 DISUBSTR 题目描述: Given a string, we need to find the total number of its distinct substrings. 输入格式: T- number of test cases. T<=20; Each test case consists of one string, whose length is <= 1000 输出格式: For each test case output one number sayin…
问题: The little cat is majoring in physics in the capital of Byterland. A piece of sad news comes to him these days: his mother is getting ill. Being worried about spending so much on railway tickets (Byterland is such a big country, and he has to spe…
A musical melody is represented as a sequence of N (1<=N<=20000)notes that are integers in the range 1..88, each representing a key on the piano. It is unfortunate but true that this representation of melodies ignores the notion of musical timing; b…
Given a string, we need to find the total number of its distinct substrings. Input T- number of test cases. T<=20;Each test case consists of one string, whose length is <= 1000 Output For each test case output one number saying the number of distinc…