[SPOJ705]不同的子串】的更多相关文章

题目:http://cojs.tk/cogs/problem/problem.php?pid=1709 1709. [SPOJ705]不同的子串 ★★   输入文件:subst1.in   输出文件:subst1.out   简单对比时间限制:1 s   内存限制:256 MB [题目描述] 给定一个字符串,计算其不同的子串个数. [输入格式] 一行一个仅包含大写字母的字符串,长度<=50000 [输出格式] 一行一个正整数,即不同的子串个数. [样例输入] ABABA [样例输出] 9 [来源…
题目描述] 给定一个字符串,计算其不同的子串个数. [输入格式] 一行一个仅包含大写字母的字符串,长度<=50000 [输出格式] 一行一个正整数,即不同的子串个数. [样例输入] ABABA [样例输出] 9 题解: 显然后缀可以是一个子串,然后后缀中可能包含多个子串. 我们考虑不重复统计,容易发现 一个后缀的贡献为L-high[i]+1 因为high[i]之前的显然可以在后面的串中被统计到,所以可以避免重复 #include <algorithm> #include <iost…
http://www.spoj.com/problems/SUBST1/en/  题目链接 SUBST1 - New 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 le…
题目描述 Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 即给定一个字符串,返回该字符串最长的回文子串 如给出"acabcddcbadike",返回"abcddcba"…
题目描述 Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 即给定一个字符串,求它的最长回文子串的长度(或者最长回文子串). 解法一 对于一个问题,一定可以找到一个傻的可爱的暴力解法,本题的暴力解法即…
#include<stdio.h>#include<string.h>int substring(char *str,char *str1);//函数原型int main(void){char str[64]={0};char str1[16]={0};int i,j,x;printf("please put the string\n");gets(str);//输入的原字符串puts(str);printf("\n");printf(&qu…
Given a string S, find the length of the longest substring T that contains at most two distinct characters.For example,Given S = “eceba”,T is “ece” which its length is 3. 这道题给我们一个字符串,让我们求最多有两个不同字符的最长子串.那么我们首先想到的是用哈希表来做,哈希表记录每个字符的出现次数,然后如果哈希表中的映射数量超过两…
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example,S = "ADOBECODEBANC"T = "ABC" Minimum window is "BANC". Note:If there is no such window i…
You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters. For example, giv…
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest subst…