Spoj SUBST1 New Distinct Substrings】的更多相关文章

题目链接:https://vjudge.net/problem/SPOJ-SUBST1 SUBST1 - New Distinct Substrings #suffix-array-8 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, who…
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 <= 50000 Output For each test case output one number saying the number of disti…
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 <= 50000 Output For each test case output one number saying the number of disti…
SAM里的转台不会有重复串,所以答案就是每个right集合所代表的串个数的和 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int N=100005; int T,n,fa[N],ch[N][27],dis[N],cur=1,con=1,la; long long ans; char s[N]; void ins(int c,int id) { la=cu…
题意: 问给定串有多少本质不同的子串? 思路: 子串必是某一后缀的前缀,假如是某一后缀\(sa[k]\),那么会有\(n - sa[k] + 1\)个前缀,但是其中有\(height[k]\)个和上一个重复,那么最终的贡献的新串为\(n - sa[k] + 1 - height[k]\).故最终结果为\(\sum_{i = 1}^n (n - sa[k] + 1 - height[k])\),即 \(\frac{n * (n + 1)}{2} - \sum_{i = 1}^nheight[k]\…
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 <= 50000 Output For each test case output one number saying the number of disti…
DISUBSTR - Distinct Substrings 链接 题意: 询问有多少不同的子串. 思路: 后缀数组或者SAM. 首先求出后缀数组,然后从对于一个后缀,它有n-sa[i]-1个前缀,其中有height[rnk[i]]个被rnk[i]-1的后缀算了.所以再减去height[rnk[i]]即可. 代码: 换了板子. #include<cstdio> #include<algorithm> #include<cstring> #include<iostr…
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 <= 50000 Output For each test case output one number saying the number of disti…
\(\color{#0066ff}{ 题目描述 }\) 给定一个字符串,求该字符串含有的本质不同的子串数量. \(\color{#0066ff}{输入格式}\) T- number of test cases. T<=20; Each test case consists of one string, whose length is <= 50000 \(\color{#0066ff}{输出格式}\) For each test case output one number saying th…
题面 Vjudge Vjudge Sol 求一个串不同子串的个数 每个子串一定是某个后缀的前缀,也就是求所有后缀不同前缀的个数 每来一个后缀\(suf(i)\)就会有,\(len-sa[i]+1\)的新的前缀,又由于有\(height\)个重复的,那么就是\(len-sa[i]+1-height\)的贡献 两个就只有数组大小的区别 # include <bits/stdc++.h> # define IL inline # define RG register # define Fill(a,…