codeforces 149E . Martian Strings kmp】的更多相关文章

题目链接 给一个字符串s, n个字符串str. 令tmp为s中不重叠的两个连续子串合起来的结果, 顺序不能改变.问tmp能形成n个字符串中的几个. 初始将一个数组dp赋值为-1. 对str做kmp, 然后与串s进行匹配, 看哪些长度的串可以匹配到, 比如说匹配到了长度为j的串, 那么dp[j] = i, i是此时串s的位置. 然后将s和str都反转, 在做一次kmp, 在进行匹配, 对于匹配到的长度j, 看dp[lenStr-j]是否为-1, 如果不为-1, 看lenS-i是否大于等于dp[le…
Martian Strings 题解: 对于询问串, 我们可以从前往后先跑一遍exkmp. 然后在倒过来,从后往前跑一遍exkmp. 我们就可以记录下 对于每个正向匹配来说,最左边的点在哪里. 对于每个反向匹配来说,最右边的点在哪里. 然后判断可不可以构成这个串就好了. 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen("_in.txt","r",stdin);…
原文链接https://www.cnblogs.com/zhouzhendong/p/CF117G2.html 题目传送门 - CF177G2 题意 定义斐波那契字符串如下: $s_1="a"$ $s_2="b"$ $s_i=s_{i-1}+s_{i-2}\ \ \ \ \ (i\geq 3)$ 给定 $k,m$,以及对应的 $m$ 组询问. 每组询问一个字符串 $x$ ,问 $x$ 在 $s_k$ 中出现了多少次. $k\leq 10^{18},m\leq 10^…
题目大意 给定一个字符串T,接下来有n个字符串,对于每个字符串S,判断是否存在T[a-b]+T[c-d]=S(1 ≤ a ≤ b < c ≤ d ≤ length(T)) 题解 对于每个字符串S,我们先顺序在字符串T上进行匹配,并记录S的每个字符第一次在T上匹配到的位置(假设用数组pos记录),然后把字符串T和S都逆序,再用S在T上进行匹配,假设当前已经S匹配到第i个,在字符串T上的位置为j,S的第i+1个字符在原字符串中的位置为length(S)-i-2,T字符串的第j个字符在原字符串中的位置…
这里给出来一个后缀自动机的题解. 考虑对 $s$ 的正串和反串分别建后缀自动机. 对于正串的每个节点维护 $endpos$ 的最小值. 对于反串的每个节点维护 $endpos$ 的最大值. 这两个东西通过一个简单的基数排序就可以实现. 将 $p$ 的正串在正串的 SAM 上去匹配,一直匹配到匹配不了为止,并记录 $p[i]$ 在正串中自动机节点上 $endpos$ 的最小值 $a[i]$. 对 $p$ 的反串也进行相同的处理,记录 $endpos$ 的最大值 $b[i]$. 正串中的 $endp…
正反两遍扩展KMP,维护公共长度为L时.出如今最左边和最右边的位置. . .. 然后枚举推断... E. Martian Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output During the study of the Martians Petya clearly understood that the Mart…
Martian Strings Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 149E64-bit integer IO format: %I64d      Java class name: (Any)   During the study of the Martians Petya clearly understood that the Mar…
Power Strings Time Limit: 3000MSMemory Limit: 65536K Total Submissions: 29663Accepted: 12387 Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef…
点击打开链接 Power Strings Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 27368   Accepted: 11454 Description Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b =…
Power Strings Time Limit : 6000/3000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Total Submission(s) : 29   Accepted Submission(s) : 14 Problem Description Given two strings a and b we define a*b to be their concatenation. For example,…