随笔分类 - 字符串
摘要:题意:给定字符串S,A,B。现在让你对S进行切割,使得每个切割出来的部分在[A,B]范围内,问方案数。 思路:有方程,dp[i]=Σ dp[j] (S[j+1,i]在合法范围内)。 假设M和N的最长公共前缀为长度是LCP,那么字符串M>=字符串N的条件是 LCP=|N|或者(LCP<|N|&&M[l
阅读全文
摘要:题意:给定字符串S; Q次询问,每次询问给出(L,R,T),让你在S[L,R]里面找一个字典序最小的子串,其字典序比T大。 没有则输出-1; 思路:比T字典序大,而且要求字典最小,显然就是在T的尾巴加一个很小的字符,如果不存在,则依次删去尾巴,直到“存在”。 而“存在”是指,前缀lim+一个字符‘x
阅读全文
摘要:KMP,扩展KMP和Manacher就不写了,感觉没多大意思。 之前感觉后缀自动机简直可以解决一切,所以不怎么写后缀数组。 马拉车主要是通过对称中心解决问题,有的时候要通过回文串的边界解决问题,这个时候回文树就用到了,又好写,又强大。 之前整理过一篇后缀自动机的。感觉还要整理一下,顺便把回文树,后缀
阅读全文
摘要:Alice get a string S. She thinks palindrome string is interesting. Now she wanna know how many three tuple (i,j,k) satisfy 1≤i≤j<k≤length(S) , S[i..j]
阅读全文
摘要:Sample Input 6 1 a 1 b 2 a 2 c 3 4 8 1 a 2 a 2 a 1 a 3 1 b 3 4 Sample Output 4 5 4 5 11 题意:多组输入,开始字符串为空,支持4中操作: 1,在字符串首加字符; 2,在字符串尾加字符; 3,查询字符串不同本质的回文
阅读全文
摘要:CA loves strings, especially loves the palindrome strings. One day he gets a string, he wants to know how many palindromic substrings in the substring
阅读全文
摘要:A string is palindrome, if the string reads the same backward and forward. For example, strings like "a", "aa", "appa", "queryreuq" are all palindrome
阅读全文
摘要:A. The Fair Nut and the Best Path 题意:给定有点权,有边权的树,让你选择一条链(也可以是只有一个点),使得点权之和-边权最大。 思路:裸的树形DP,我们用dp[i]表示i的子树里某个点到i这条链的最大值,然后用次大值更新答案即可。 具体的,每个dp[i]初始化=a[
阅读全文
摘要:2124: 等差子序列 Description 给一个1到N的排列{Ai},询问是否存在1<=p1<p2<p3<p4<p5<…<pLen<=N (Len>=3), 使得Ap1,Ap2,Ap3,…ApLen是一个等差序列。 给一个1到N的排列{Ai},询问是否存在1<=p1<p2<p3<p4<p5<…
阅读全文
摘要:3297: [USACO2011 Open]forgot Description 发生了这么多,贝茜已经忘记了她cowtube密码。然而,她记得一些有用的信息。首先,她记得她的密码(记为变 量P)长度为L(1 <= L<=1,000)字符串,并可以被分成 一个或多个词(不一定是唯一的),词来自于字典
阅读全文
摘要:3207: 花神的嘲讽计划Ⅰ Description 背景 花神是神,一大癖好就是嘲讽大J,举例如下: “哎你傻不傻的!【hqz:大笨J】” “这道题又被J屎过了!!” “J这程序怎么跑这么快!J要逆袭了!” …… 描述 这一天DJ在给吾等众蒟蒻讲题,花神在一边做题无聊,就跑到了一边跟吾等众蒟蒻一起
阅读全文
摘要:题目描述 一个串T是S的循环节,当且仅当存在正整数k,使得S是T k Tk (即T重复k次)的前缀,比如abcd是abcdabcdab的循环节。给定一个长度为n的仅由小写字符构成的字符串S,请对于每个k(1<=k<=n),求出S长度为k的前缀的最短循环节的长度per i peri 。字符串大师小Q觉
阅读全文
摘要:One day Silence is interested in revolving the digits of a positive integer. In the revolving operation, he can put several last digits to the front o
阅读全文
摘要:Give you a string with length N, you can generate N strings by left shifts. For example let consider the string “SKYLONG”, we can generate seven strin
阅读全文
摘要:You are given a string ss. You should answer nn queries. The ii-th query consists of integer kiki and string mimi. The answer for this query is the mi
阅读全文
摘要:题意:给定字符串char[],以及Q个操作,操作有三种: 1:pos,chr:把pos位置的字符改为chr 2:pos:问以pos为中心的回文串长度为多长。 3:pos:问以pos,pos+1为中心的回文串长度为多长。 思路:用hash表示一段字符串或者连续子串。我们用BIT记录hash前缀和,那么
阅读全文
摘要:After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; const int maxn=100010; int num[26],used[26]; char c[maxn],ans[maxn]; int main() { int L,i; scanf("%s",c+1
阅读全文
摘要:我们定义2个字符串的相似度等于两个串的相同前缀的长度。例如 "abc" 同 "abd" 的相似度为2,"aaa" 同 "aaab" 的相似度为3。 给出一个字符串S,计算S同他所有后缀的相似度之和。例如:S = "ababaa",所有后缀为: ababaa 6 babaa 0 abaa 3 baa
阅读全文
摘要:Taplu and Abhishar loved playing scrabble. One day they thought of inventing a new game using alphabet tiles. Abhishar wrote a string using tiles and
阅读全文