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…
DISUBSTR - Distinct Substrings no tags  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…
New Distinct Substrings 题目大意 给定一个字符串,求本质不同的子串个数 题解 SA常见思想:每一个子串都是某个后缀的前缀 考虑每一个后缀的贡献,首先他拥有n - sa[i]个(我是用的模板中,sa[i]的大小是0....n-1)前缀,这些前缀有height[i]个跟sa[i-1]相同,要减去.剩下的部分不可能与sa[i-1]之前的想通了,不然sa[i]会排在sa[i-1]前面 还要注意本题的字符集是小写字母(鬼知道样例是什么东西) #include <cstdio> #…
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…
https://vjudge.net/problem/SPOJ-DISUBSTR https://www.luogu.org/problemnew/show/SP694 http://www.spoj.com/problems/DISUBSTR/en/ 给定一个字符串,求不相同的子串的个数. 参考罗穗骞论文. 显然一个子串可以定义为一个后缀的前缀. 我们还可以求出来相邻排名的后缀之间的最长公共前缀的长度. 答案就是所有子串数量-所有height. (其实大胆猜想,不用证明即可(滑稽)) 说下原理…
题意:统计母串中包含多少不同的子串 然后这是09年论文<后缀数组——处理字符串的有力工具>中有介绍 公式如下: 原理就是加上新的,减去重的,这题是因为打多校才补的,只能说我是个垃圾 #include <iostream> #include <cmath> #include <cstdio> #include <cstring> #include <cstdlib> #include <string> #include &l…
思路 求本质不同的子串个数,总共重叠的子串个数就是height数组的和 总子串个数-height数组的和即可 代码 #include <cstdio> #include <algorithm> #include <cstring> #define int long long const int MAXN = 100000; using namespace std; int height[MAXN],sa[MAXN],ranks[MAXN],barrel[MAXN],n;…
/* 统计每个节点的max和min, 然后求和即可 min = max[fa] + 1 */ #include<cstdio> #include<algorithm> #include<iostream> #include<cstring> #include<queue> #define ll long long #define M 6010 #define mmp make_pair using namespace std; int read(…
求不相同子串个数    该问题等价于求所有后缀间不相同前缀的个数..也就是对于每个后缀suffix(sa[i]),将贡献出n-sa[i]+1个,但同时,要减去那些重复的,即为height[i],故答案为n-sa[i]+1-height[i]的累计. ; var x,y,rank,sa,h,c:..maxn] of longint; s:ansistring; t,q,n:longint; function max(x,y:longint):longint; begin if x>y then e…
DISUBSTR - Distinct Substrings   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 nu…