luoguP2679 子串】的更多相关文章

luoguP2679 子串 个人感觉\(noip\)系列中挺好的一道DP题目. 题面有点难理解. 我们设\(f_{i,j,k,0/1}\)表示\(A\)串前\(i\)个字符,匹配\(B\)串前\(j\)个字符,正在用第\(k\)的子串,且第\(i\)个字符选或者不选的方案数 则有\(f_{i,j,k,0} = f_{i - 1,j,k,0} + f_{i - 1,j,k,1}\) 如果\(A_i == A_j\),那么有 \(f_{i,j,k,1} = f_{i - 1,j - 1,k - 1,…
传送门 气死我了,自己YY的方法只能得70分. 一个下午都在搞这道题. 至于正解,真的不想写了. 请移步 here #include <cstdio> #define M 201 #define N 1001 #define p 1000000007 #define LL long long int n, m, t; char A[N], B[M]; LL f[2][M][M], sum[2][M][M]; int main() { int i, j, k; scanf("%d %d…
AC通道! 题目大意: 给定两个长度分别为 n 和 m 的字符串 A 和 B,选取 A 中的 k 个子串,使这 k 个子串按照先后顺序连接起来后等于 B 子串.   输入输出样例 输入 #1 6 3 1 aabaab aab 输出 #1 2   输入 #2 6 3 2  abaab  aab 输出 #2 7   输入 #3 6 6 3 aabaab aab 输出 #3 7   首先,看题目的要求.对于这类题目要求,以及如此之小的数据范围,考虑使用动态规划. /*-----------------…
题目描述 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…