E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
Substrings
POJ 3415 Common
Substrings
http://poj.org/problem?id=3415cnt代表节点所接受的字符在原串中出现的次数ml表示该状态能接受的最长的字符串长度那么我们可以知道一个状态(设为rt)所能接受的最短的字符串长度为ml[pa[rt]]+1设tmp为当前状态所能接受的字符串长度那么,一个节点rt,所能接受的字符串在原字符串中所能接受的次数就是cnt[rt]*(tmp-ml[pa[rt]]+1)那么,因为我们
My_stage
·
2020-09-17 05:04
字符串
Common
Substrings
POJ - 3415(后缀自动机)
https://vjudge.net/problem/POJ-3415其实很早以前这道题就过了,但不过因为后缀数组的方法自己也不是很懂就没有写。今天我学了一下后缀自动机,我们利用后缀自动机解决。首先对A串建立后缀自动机,然后对每一个非克隆结点进行标记,然后建一颗fail树,用一个dfs进行计数,这个步骤就是其他博客上写的拓扑排序。首先对于一个结点,他所包含的子串个数为len[i]−lenk[lin
KXL5180
·
2020-09-17 05:32
字符串
POJ 3415-Common
Substrings
(后缀数组+单调栈-公共子串的长度)
CommonSubstringsTimeLimit:5000MSMemoryLimit:65536KTotalSubmissions:10850Accepted:3587DescriptionAsubstringofastringTisdefinedas:T(i,k)=TiTi+1...Ti+k-1,1≤i≤i+k-1≤|T|.GiventwostringsA,BandoneintegerK,we
kewlgrl
·
2020-09-17 05:32
POJ
高级计划
ACM_KMP/后缀数组
POJ 3415 Common
Substrings
(后缀数组+单调栈)
转载请注明出处,谢谢http://blog.csdn.net/acm_cxlove/article/details/7854526by---cxlove题目:求出长度不小于k的公共子串个数http://poj.org/problem?id=3415继续论文上的题目。计算A的某个后缀与B的某个后缀的最长公共前缀长度,如果长度L大于k,则加上L-k+1组。将两个字符串连接起来,中间用一个没有出现的字符
ACM_cxlove
·
2020-09-17 05:58
ACM_字符串
leetcode647回文子串
##1、题目https://leetcode-cn.com/problems/palindromic-
substrings
/submissions/2、题意题解1:写了个暴力虽然过了时间复杂度很高classSolution
everlasting_lxy
·
2020-09-16 10:47
leetcode
leetcode
【LeetCode】647. 回文子串
题目链接:https://leetcode-cn.com/problems/palindromic-
substrings
/description/题目描述给定一个字符串,你的任务是计算这个字符串中有多少个回文子串
fuqiuai
·
2020-09-16 09:55
LeetCode
Good
Substrings
http://codeforces.com/contest/316/problem/G3SAM上DP在某岛的博客上看到的,要义就是一个串的子串必然是该串某个后缀的前缀,所以从表示该状态的子串节点往后走必然会走到那个串的尾节点。#include#include#include#include#include#include#include#include#include#include#includ
gyarenas
·
2020-09-15 19:01
动态规划
串
数据结构
Leetcode 1190.反转每对括号间的子串(Reverse
Substrings
Between Each Pair of Parentheses)
Leetcode1190.反转每对括号间的子串1题目描述(Leetcode题目链接) 给出一个字符串s(仅含有小写英文字母和括号)。请你按照从括号内到外的顺序,逐层反转每对匹配括号中的字符串,并返回最终的结果。注意,您的结果中不应包含任何括号。输入:s="(abcd)"输出:"dcba"输入:s="(ed(et(oc))el)"输出:"leetcode"输入:s="a(bcdefghijkl(m
就叫昵称吧
·
2020-09-15 01:19
Leetcode
栈
leetcode
算法
Reverse
Substrings
Between Each Pair of Parentheses
LeetCode-1190.ReverseSubstringsBetweenEachPairofParenthesesYouaregivenastringsthatconsistsoflowercaseEnglishlettersandbrackets.Reversethestringsineachpairofmatchingparentheses,startingfromtheinnermost
Bob__yuan
·
2020-09-15 00:13
#
编程题
LeetCode
Algorithm
Count Binary
Substrings
LWC54:696.CountBinarySubstrings传送门:696.CountBinarySubstringsProblem:Giveastrings,countthenumberofnon-empty(contiguous)substringsthathavethesamenumberof0’sand1’s,andallthe0’sandallthe1’sinthesesubstrin
Demon的黑与白
·
2020-09-14 20:24
算法竞赛
算法集中营
Awesome
Substrings
(思维 + 分块暴力)
要求的是所有的l,r使得:r−l=k∗(sum[r]−sum[l])r-l=k*(sum[r]-sum[l])r−l=k∗(sum[r]−sum[l])设置一个块大小block,枚举1的个数x,按block分块若x≤blockx\leqblockx≤block,O(n)枚举左端点统计所有右端点,复杂度为O(block∗n)O(block*n)O(block∗n)若x>blockx>blockx>b
猝死在学ACM的路上
·
2020-09-14 20:28
分块
思维
分块暴力
实现
暴力
思维
字符串
Palindromic
Substrings
诚然,不言暴力法。动态规划和中心扩展法较为合适。classSolution{publicStringlongestPalindrome(Strings){intn=s.length();Stringres="";boolean[][]dp=newboolean[n][n];for(inti=n;i>=0;i--){for(intj=i;jres.length())){res=s.substring
Taohongfei_huster
·
2020-09-14 15:10
字符串
动态规划
LeetCode 647 : Palindromic
Substrings
(java)
原题Givenastring,yourtaskistocounthowmanypalindromicsubstringsinthisstring.Thesubstringswithdifferentstartindexesorendindexesarecountedasdifferentsubstringseventheyconsistofsamecharacters.Example1:Input
marlonlyh
·
2020-09-12 19:53
leetcode
java
Palindromic
Substrings
【动态规划 + 回文 + 对称性】
题目Givenastring,yourtaskistocounthowmanypalindromicsubstringsinthisstring.Thesubstringswithdifferentstartindexesorendindexesarecountedasdifferentsubstringseventheyconsistofsamecharacters.Example1:Input
TheSnowBoy_2
·
2020-08-25 17:19
算法练手
Palindromic
Substrings
(回文子字符串)
原题Givenastring,yourtaskistocounthowmanypalindromicsubstringsinthisstring.Thesubstringswithdifferentstartindexesorendindexesarecountedasdifferentsubstringseventheyconsistofsamecharacters.Example1:Input
dby_freedom
·
2020-08-25 15:41
LeetCode
647. 回文子串
题目链接:https://leetcode-cn.com/problems/palindromic-
substrings
/description/基于动态规划-1这题基于动态规划的思想来解答的话,实现思想参考自
OneDeveloper
·
2020-08-25 11:12
LeetCode
渣渣的算法历练之路
Palindromic
Substrings
回文子串
给定一个字符串,你的任务是计算这个字符串中有多少个回文子串。具有不同开始位置或结束位置的子串,即使是由相同的字符组成,也会被视作不同的子串。示例1:输入:"abc"输出:3解释:三个回文子串:"a","b","c"示例2:输入:"aaa"输出:6解释:6个回文子串:"a","a","a","aa","aa","aaa"提示:输入的字符串长度不会超过1000。暴力枚举首先想到的就是枚举所有的子串,然
Alex 007
·
2020-08-25 09:56
#
LeetCode
LeetCode 647. 回文子串 | Python
647.回文子串题目来源:力扣(LeetCode)https://leetcode-cn.com/problems/palindromic-
substrings
题目给定一个字符串,你的任务是计算这个字符串中有多少个回文子串
"大梦三千秋
·
2020-08-25 05:46
LeetCode
leetcode
算法
动态规划
python
647.
回文子串
字符串Hash例题详解
Catalogue1.Codeforces898FRestoringtheExpression2.Codeforces961Fk-
substrings
3.Codeforces985FIsomorphicStrings4
南判
·
2020-08-25 00:15
Problemset
Palindromic
Substrings
(Leetcode每日一题-2020.08.19)
ProblemGivenastring,yourtaskistocounthowmanypalindromicsubstringsinthisstring.Thesubstringswithdifferentstartindexesorendindexesarecountedasdifferentsubstringseventheyconsistofsamecharacters.Note:Thei
Bryan要加油
·
2020-08-24 16:17
leetcode动态规划
leetcode字符串
SPOJ 题目705 New Distinct
Substrings
(后缀数组,求不同的子串个数)
SUBST1-NewDistinctSubstringsnotagsGivenastring,weneedtofindthetotalnumberofitsdistinctsubstrings.InputT-numberoftestcases.T#include#include#include#definemin(a,b)(a>b?b:a)#definemax(a,b)(a>b?a:b)using
Jogging_Clown
·
2020-08-24 11:12
后缀数组
SPOJ 694 Distinct
Substrings
后缀数组求不同的子串数。。每一个子串都是某个后缀的前缀,每加入一个后缀都会增加n-sa[i]个子串,但是有h[i]个子串会是重复的,所以对每增加的一个后缀会产生n-sa[i]-h[i]个不同的子串DistinctSubstringsTimeLimit:1000MSMemoryLimit:Unknown64bitIOFormat:%lld&%llu[Submit][GoBack][Status]De
码代码的猿猿的AC之路
·
2020-08-24 10:05
字符串
SPOJ - DISUBSTR Distinct
Substrings
(后缀数组求不相同的子串个数)
DescriptionGivenastring,weneedtofindthetotalnumberofitsdistinctsubstrings.InputT-numberoftestcases.T#include#include#include#includeusingnamespacestd;constintmaxn=1010;intsa[maxn];//SA数组,表示将S的n个后缀从小到大
Joyyiwei
·
2020-08-24 10:42
后缀数组
SPOJ DISUBSTR - Distinct
Substrings
or SUBST1 - New Distinct
Substrings
【不同子串数目】
题目1链接:SPOJDISUBSTR-DistinctSubstrings题目1链接:SPOJSUBST1-NewDistinctSubstringsDISUBSTR-DistinctSubstringsnotagsGivenastring,weneedtofindthetotalnumberofitsdistinctsubstrings.InputT-numberoftestcases.T#in
笑着走完自己的路
·
2020-08-24 08:06
后缀数组
SPOJ DISUBSTR - Distinct
Substrings
后缀数组,转化
DISUBSTR-DistinctSubstringsnotagsGivenastring,weneedtofindthetotalnumberofitsdistinctsubstrings.InputT-numberoftestcases.Tsa[len]的方向计算,每一次可以有len-sa[i]+1个新子串(这个后缀的前缀数),可是考虑重复的问题,需要减去height[i]也就是和上一个后缀的
Good_night_Sion_
·
2020-08-24 07:04
后缀数组
SP694 DISUBSTR - Distinct
Substrings
(洛谷 字典树)
题目链接:https://www.luogu.com.cn/problem/SP694题意t组测试样例,每组给一个字符串求该字符串本质不同的子串的个数思路子串其实就是字符串后缀的前缀。比如给一个串是“abaab”,则"aa"是后缀“aab”的前缀。要算前缀种数,就要马上想到字典树啦,它可以很方便的求出字符串前缀的种数。不过这道题把时间卡的死死的,初始化的时候要注意,还有就是字符串得定义成char类
chasing__wind
·
2020-08-24 07:52
字典树
Unique
Substrings
in Wraparound String
Considerthestringstobetheinfinitewraparoundstringof"abcdefghijklmnopqrstuvwxyz",soswilllooklikethis:"...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....".Nowwehaveanotherstringp.Yourjobis
sherwin29
·
2020-08-24 00:06
Unique
Substrings
in Wraparound String
classSolution(object):deffindSubstringInWraproundString(self,p):""":typep:str:rtype:int"""iflen(p)<=1:returnlen(p)res=collections.defaultdict(int)res[p[0]]=1#dp[i]representnumberofstringsendwithp[i]dp
阿团相信梦想都能实现
·
2020-08-23 22:24
Unique
Substrings
in Wraparound String
https://leetcode.com/problems/unique-
substrings
-in-wraparound-string/description/解题思路:对于abc求它们的unique
becauseyou_90cd
·
2020-08-23 07:50
CodeForces - 914F
Substrings
in a String
题意:给定一个字符串sss,qqq次操作:①1,i,c1,i,c1,i,c,将sis_isi改为ccc;②2,l,r,t2,l,r,t2,l,r,t,求串ttt在s[l⋯r]s[l\cdotsr]s[l⋯r]中出现的次数。(∣s∣,q,Σ∣t∣≤105)(|s|,~q,~\Sigma|t|\leq10^5)(∣s∣,q,Σ∣t∣≤105)链接:https://codeforces.com/prob
freeze up
·
2020-08-23 03:42
字符串
Substrings
in a String bitset
【题目】F.SubstringsinaString【题意】给定小写字母字符串s,支持两种操作:1.修改某个位置的字符,2.给定字符串y,查询区间[l,r]内出现y多少次。|s|,Σ|y|<=10^5,time=6s。【算法】Bitset【题解】假设S的长度为n,那么对每个字符建一个长度为n的bitset,1表示该位置为该字符,修改时直接修改。查询的时候将字符串y所有的字符的bitset,按顺序错位
weixin_34247299
·
2020-08-23 03:22
数据结构与算法
Substrings
in a String(bitset)
比赛的时候怎么没看这题啊...血亏TT对每种字符建一个bitset,修改直接改就好了,查询一个区间的时候对查询字符串的每种字符错位and一下,然后用biset的count就可以得到答案了。。。#include#include#include#include#include#include#definelllonglongusingnamespacestd;constintmaxn=100010,i
weixin_30456039
·
2020-08-23 03:51
Codeforces 451D Count Good
Substrings
(组合数学)
题目链接:Codeforces451DCountGoodSubstrings题目大意:定义goodstring,就是就一个字符串的连续相同字符用一个该字符替代后,形成回文串的字符串。现在给出一个字符串,问说该字符串的子串中,为goodstring的串有多少个,分长度为奇数和偶数的输出。解题思路:因为字符串的组成为a和b,所以只要是头尾相同的子串都是满足的。所以我们计算在奇数和偶数位置的奇数个数和偶
JeraKrs
·
2020-08-23 03:07
CF
GRADE:C
数学-组合数学
Codeforces 917F
Substrings
in a String - 后缀自动机 - 分块 - bitset - KMP
题目传送门传送点I传送点II传送点III题目大意给定一个字母串,要求支持以下操作:修改一个位置的字母查询一段区间中,字符串$s$作为子串出现的次数Solution1Bitset每次匹配一段,可以看成,依次考虑每个位置,匹配的位置对应的起点取交集。例如:大概就这个意思。bitset的count似乎很慢,可以用__builtin_popcount来数中间的位数,然后暴力数两端的位数会快很多。感觉手写倍
adx33526
·
2020-08-23 01:18
Palindromic
Substrings
回文子串【Medium】【Python】【中心扩展】【动态规划】
LeetCode0647.PalindromicSubstrings回文子串【Medium】【Python】【中心扩展】【动态规划】ProblemLeetCodeGivenastring,yourtaskistocounthowmanypalindromicsubstringsinthisstring.Thesubstringswithdifferentstartindexesorendindex
Wonz
·
2020-08-23 01:18
LeetCode个人题解
#
动态规划
#
字符串
python
leetcode
动态规划
字符串
算法
Codeforces——914F
Substrings
in a String
大致题意:给一个字符串str,再给n次操作,其中1操作是改变str中pos位置的字符,2操作是查询[l,r]中字符串s出现的次数。第一次用bitset,感觉真是个好东西。真好用。洛谷上面有人写了题解,但是没有写的很具体,所以从来没写过bitset的我就只能一直猜他代码的意思,花了一点时间才搞懂了bitset,其实就是先暴力统计每种字符的位置,然后再用一个temp(bitset类型)去统计每次要查询
C画中仙
·
2020-08-23 00:38
字符串
C++ LeetCode 每日一题 - 回文子串
题目链接:https://leetcode-cn.com/problems/palindromic-
substrings
/Description给定一个字符串,你的任务是计算这个字符串中有多少个回文子串
叶子_Y
·
2020-08-21 18:39
简单算法题—LeetCode
leetcode
字符串
Palindromic
Substrings
题目Givenastring,yourtaskistocounthowmanypalindromicsubstringsinthisstring.Thesubstringswithdifferentstartindexesorendindexesarecountedasdifferentsubstringseventheyconsistofsamecharacters.Example1:Input
liuqinh2s
·
2020-08-20 20:01
leetcode
算法
字符串处理
动态规划
Palindromic
Substrings
题目Givenastring,yourtaskistocounthowmanypalindromicsubstringsinthisstring.Thesubstringswithdifferentstartindexesorendindexesarecountedasdifferentsubstringseventheyconsistofsamecharacters.Example1:Input
liuqinh2s
·
2020-08-20 20:01
leetcode
算法
字符串处理
动态规划
Palindromic
Substrings
(java)
Givenastring,yourtaskistocounthowmanypalindromicsubstringsinthisstring.Thesubstringswithdifferentstartindexesorendindexesarecountedasdifferentsubstringseventheyconsistofsamecharacters.Example1:Input:"
katrina95
·
2020-08-19 18:26
dp
Codeforces Round #166 (Div. 2) D - Good
Substrings
题意说的很清楚了,就是要寻找满足某一条件的不同字串个数。方法一:寻找不同字串个数体型很直接的一种方法就是把字符串hash值保存在set或者数组中,统计其中不同的个数。//一个长为n的字符串的字串个数为n*(n+1)/2#include#include#include#include#include#definemultiple1000000007//这里multiple如果选的太小(31,37,4
Benzema67
·
2020-08-18 09:32
codeforces
Rabin
Karp
Codeforces550A Two
Substrings
暴力
题意:给出一个串,若能找出一组AB和BA,且互不重合。思路:离散化后暴力找匹配。#includeusingnamespacestd;constintMAXN=1e5+10;intflag1[MAXN];intflag2[MAXN];intmain(){//ios::sync_with_stdio(false);chara[MAXN];while(~scanf("%s",a)){memset(fla
azure1cloud
·
2020-08-18 07:24
——————基础——————
>水题<
Palindromic
Substrings
Givenastring,yourtaskistocounthowmanypalindromicsubstringsinthisstring.Thesubstringswithdifferentstartindexesorendindexesarecountedasdifferentsubstringseventheyconsistofsamecharacters.Example1:Input:"
673556617-real
·
2020-08-17 21:17
算法
leetcode
Palindromic
Substrings
回文子串 解题报告
这道题,就是找出一个字符串中所有可能出现的回文子串的个数。做法嘛,就是一个个位置的统计,使用中心向外拓展的方法:1、每个字符自己构成回文,+12、中心拓展,假设当前位置i为回文的中心,那么设置left=i-1right=i+1,比较left与right位置是否相同,相同就+1,然后各自移动一步,重复直到退出3、中心拓展当前的回文长度是偶数的,那么就设置left=i,right=i+1,其他同2一样
学术状态抽奖器
·
2020-08-17 20:53
leetcode-java
leetcode
Atcoder Panasonic Programming Contest 2020 E Three
Substrings
题意:给你三个串(长度<=2000),串中含有的'?'字符可以匹配成任意字符,这三个串是取自同一个主串的子串,求这个主串的最长长度这个题好好分析下其实不难,就是个模拟然后的话,这题很容易想歪,我一开始想,啊,是求三个串的最长公共子串吧,然后又想,唉,只能用SAM,很麻烦,而且完全不会想歪了!这么求怎么可能对嘛,它取自同一主串,你匹配上最长公共子串,但是这三串前后都不一样怎么行啊,同一主串啊既然是同
でこもり さなえ
·
2020-08-17 07:53
Short
Substrings
(思维)
A.ShortSubstrings题目大意:(文末有原题)一个字符串s,从s[0]开始到s[len-2],每相邻两个字符(a[0]a[1]、a[1]a[2])是一个子串然后排列下去;给出一个字符串,这个字符串是通过这样获得的,求原字符串;思路:原函数每两个相邻的都会构成一个子串都会输出,所以原字符串s从s[1]开始,都会存在重复的s[i](除了最后一个),所以,我们只需保证每次都输出两个中的一个就
Aurox_
·
2020-08-17 05:51
Codeforces 519D - A and B and Interesting
Substrings
(思维)
题意要求找到子串的个数,使满足以下两个条件。i+1~j-1位置的字母的权之和为0.str[i]=str[j]思路一开始YY了半天,没思路。后来想到第一个条件,可以通过前缀和sum[j−1]=sum[i]得出。又想到如果我把每个字母对应的前缀和都存起来,这样就可以快速得到答案了。所以开一个26大的map数组,里面存的是对应的字符,所在位置的前缀和,和这个前缀和的出现次数。遍历一遍字符。当查到到i这个
IceIceBear
·
2020-08-17 03:45
CodeForces
POJ-3415-Common
Substrings
(后缀数组+单调栈)
链接:http://poj.org/problem?id=3415求两串中长度大于k的公共子串有多少个。公共子串可以通过height求,中间分隔连接两串,将height[i]>=k进行分组,对于一组内的height[i],且sa[i]属于a串,需要找到ji]-k),采用单调栈维护一个栈顶最小的height[i],大于栈顶压入,小于更新。每次针对a/b串找前面的b/a串,跑两次。//#include
EIKY
·
2020-08-17 01:21
POJ
字符串
字符串-LeetCode696. 计数二进制子串
1、题目描述https://leetcode-cn.com/problems/count-binary-
substrings
/给定一个字符串s,计算具有相同数量0和1的非空(连续)子字符串的数量,并且这些子字符串中的所有
NLP_victor
·
2020-08-16 18:18
String
字符串
K - Repeated
Substrings
题目GivenaninputstringcomposedsolelyoflowercaseEnglishletters,findthelongestsubstringthatoccursmorethanonceintheinputstring.Thetwooccurrencesareallowedtopartiallyoverlap.InputTheinputisasinglelinecontai
lqvir
·
2020-08-15 17:54
acm竞赛
二分法
上一页
1
2
3
4
5
6
7
8
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他