[SPOJ8222]Substrings】的更多相关文章

[SPOJ8222]Substrings 试题描述 You are given a string S which consists of 250000 lowercase latin letters at most. We define F(x) as the maximal number of times that some string with length x appears in S. For example for string 'ababa' F(3) will be 2 beca…
题目大意:给一个字符串S,令F(x)表示S的所有长度为x的子串中,出现次数的最大值.F(1)..F(Length(S)) 建出SAM, 然后求出Right, 求Right可以按拓扑序dp..Right就是某个点到结束状态的路径数, parent树上last的那一条链都是结束状态...然后用Right去更新答案.. spoj卡常数..一开始用DFS就炸了, 改用BFS就A了.. (贴一下丽洁姐的题解: 我们构造S的SAM,那么对于一个节点s,它的长度范围是[Min(s),Max(s)],同时他的出…
http://www.spoj.com/problems/NSUBSTR/ (题目链接) 题意 给出一个字符串S,令${F(x)}$表示S的所有长度为x的子串出现次数的最大值.求${F(1)......F(length(S))}$ Solution 后缀自动机例题,下面写几点自己认为理解后缀自动机的重点. 后缀自动机相对于后缀树就是将Right集合相同的子串合用一个节点来表示.每一个节点代表一个状态S,这个状态可能包含很多长度区间连续的子串,这些子串的右端点固定,它们的Right集合相同. 往上…
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump/转载请注明出处,侵权必究,保留最终解释权! 题目链接:SPOJ8222 正解:后缀自动机 解题报告: 我好菜啊,现在才学SAM… 大概的构造就是在线的增量法,看看代码还是挺好懂的,简洁明了… 有几个基础性质:自动机上的每个点上代表的字符串集合的右端点相同,$right$集合相同. 而且两个点的$ri…
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #define maxn 500005 #define maxm 250005 using namespace std; ],dist[maxn],ri[maxn],sum[maxm],tmp[maxn]; char st[maxm]; struct Tseg…
You are given a string \(S\) which consists of 250000 lowercase latin letters at most. We define \(F(x)\) as the maximal number of times that some string with length \(x\) appears in \(S\). For example for string 'ababa' \(F(3)\) will be 2 because th…
https://www.luogu.org/problemnew/show/SP8222#sub http://www.spoj.com/problems/NSUBSTR/ 翻译来自洛谷. 你得到一个字符串,最多由25万个小写拉丁字母组成.我们将 F(x)定义为某些长度X的字符串在s中出现的最大次数,例如字符串'ababaf'- F(x),因为有一个字符串'ABA'出现两次.你的任务是输出 F(x)每一个I,以使1<=i<=|S|. water! 后缀自动机后对l排个序,对每个l更新其ans就…
You are given a string S which consists of 250000 lowercase latin letters at most. We define F(x) as the maximal number of times that some string with length x appears in S. For example for string 'ababa' F(3) will be 2 because there is a string 'aba…
讲起来不是特别好讲.总之,如果 $dp[i+1]>=dp[i]$,故$dp[i]=max(dp[i],dp[i+1])$ Code: #include <cstdio> #include <algorithm> #include <cstring> #define setIO(s) freopen(s".in","r",stdin) #define maxn 2000000 #define N 30 #define ll l…
题意: 给一个字符串S,令F(x)表示S的所有长度为x的子串中,出现次数的最大值. 求F(1)..F(Length(S)) Length(S) <= 250000 思路:板子中st[x]定义为root到x的最多步数,可以用来更新所有长度为[1..st[x]]的答案 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned int uint; typedef unsigned lo…
Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this: "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....". Now we have another string p. Your job is to find…
Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this: "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....". Now we have another string p. Your job is to find…
Description String analysis often arises in applications from biology and chemistry, such as the study of DNA and protein molecules. One interesting problem is to find how many substrings are repeated (at least twice) in a long string. In this proble…
Codeforces Round #258 (Div. 2) Count Good Substrings D. Count Good Substrings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output We call a string good, if after merging all the consecutive eq…
题目 Source http://acm.hust.edu.cn/vjudge/problem/19225 Description The Hamming distance between two strings of the same length is defined as the number of positions at which the corresponding characters are different. For example, the Hamming distance…
Description 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 num…
题意:由a和b构成的字符串,如果压缩后变成回文串就是Good字符串.问一个字符串有几个长度为偶数和奇数的Good字串. 分析:可知,因为只有a,b两个字母,所以压缩后肯定为..ababab..这种形式,所以是good substrings,那么首尾字符肯定相同,于是就好搞了. 用:odd[0],odd[1]分别记录奇数位置上出现的a和b的个数,even[0],even[1]分别记录偶数位置上的a,b个数. 那么到一个奇数点时,奇数长度的子串个数应该加上奇数位置的该字符的个数,偶数长度的应该加上偶…
694. Distinct Substrings Problem code: DISUBSTR   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 c…
A. Two Substrings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/problem/A Description You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "…
Two Substrings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and…
#1152 : Lucky Substrings 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 A string s is LUCKY if and only if the number of different characters in s is a fibonacci number. Given a string consisting of only lower case letters, output all its lucky non-empty sub…
http://poj.org/problem?id=3415 Common Substrings Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 5805   Accepted: 1911 Description A substring of a string T is defined as: T(i, k)=TiTi+1...Ti+k-1, 1≤i≤i+k-1≤|T|. Given two strings A, B an…
Substrings Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6238    Accepted Submission(s): 2767 Problem Description You are given a number of case-sensitive strings of alphabetic characters, fi…
题目链接:D. A and B and Interesting Substrings 题目大意 给定26个小写字母的权值,一共26个整数(有正有负). 给定一个小写字母组成的字符串(长度10^5),求有多少长度大于1的子串满足: 1)首尾字符相同. 2)除了首尾字符外,其他字符的权值和为0. 题目分析 使用STL Map.开26个Map,给每个字母开一个. 先求出权值的前缀和 Sum[] . 然后1到l枚举每一位字符,如果是a,那么 Ans += Map[a][Sum[i - 1]]; 然后 +…
Description If a string is in the form UVU, where U is not empty, and V has exactly L characters, we say UVUis an L-Gap string. For example, abcbabc is a 1-Gap string. xyxyxyxyxy is both a 2-Gap stringand also a 6-Gap string, but not a 10-Gap string…
Common Substrings Description A substring of a string T is defined as: T(i, k)=TiTi+1...Ti+k-1, 1≤i≤i+k-1≤|T|. Given two strings A, B and one integer K, we define S, a set of triples (i, j, k): S = {(i, j, k) | k≥K, A(i, k)=B(j, k)}. You are to give…
Common Substrings   Description A substring of a string T is defined as: T(i, k)=TiTi+1...Ti+k-1, 1≤i≤i+k-1≤|T|. Given two strings A, B and one integer K, we define S, a set of triples (i, j, k): S = {(i, j, k) | k≥K, A(i, k)=B(j, k)}. You are to giv…
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…
Icerain likes strings very much. Especially the strings only consist of 0 and 1,she call them easy strings. One day, she is so boring that she want to find how many good substrings in an easy string? A good substring is a substring which can be a pal…
Substrings Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8183    Accepted Submission(s): 3752 Problem Description You are given a number of case-sensitive strings of alphabetic characters, fin…