CF1183E/H Subsequences】的更多相关文章

思路: dp好题,dp[i][j]表示到前i个字符为止并且以s[i]为结尾,共有多少个长度为j的不同的子序列. 实现: #include <bits/stdc++.h> using namespace std; typedef long long ll; ll dp[][], sum[]; ]; int main() { int n; ll m; string s; while (cin >> n >> m >> s) { memset(dp, , size…
H. Subsequences (hard version) 这个题目好难啊,根本就不知道怎么dp,看了题解,理解了好一会才会的. 首先dp[i][j] 表示前面 i  个字符,形成长度为 j  的不同子字符串的个数. dp[i][j]=dp[i-1][j-1]+dp[i][j-1]  这个就是说这个字符选还是不选. 但是需要注意的是,这个会有重复的字符,如果碰到重复的字符了,这样转移就会出现一点问题,这样会多加了一些情况. 比如说 xyzabca  dp[7][2] 就是在前面7个字符里面选长…
题目链接: C. Subsequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2227 Find the nondecreasing subsequences                                  Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)                                             …
H. Hashing time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output In this problem you are given a byte array a. What you are going to do is to hash its subsequences. Fortunately you don't have to…
Friends and Subsequences 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/H Description Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on the…
C. Subsequences Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem/C Description For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed tha…
Status of This Memo This document specifies an Internet standards track protocol for the   Internet community, and requests discussion and suggestions for   improvements.  Please refer to the current edition of the "Internet   Official Protocol Stand…
题目连接:10069 - Distinct Subsequences 题目大意:给出两个字符串x (lenth < 10000), z (lenth < 100), 求在x中有多少个z. 解题思路:二维数组DP, 有类似于求解最长公共子序列, cnt[i][j]表示在x的前j个字符中有多少个z 前i个字符. 状态转移方程 1.x[j] != z[i]              cnt[i][j] = cnt[i][j - 1]; 2.x[j] == z[i]   cnt[i][j] = cnt…
题目链接: Subsequences in Substrings Kattis - subsequencesinsubstrings 题目大意:给你字符串s和t.然后让你在s的所有连续子串中,找出这些连续子串中的非连续子串中包含t的有多少个. 具体思路:我们枚举s的每一个位置,然后判断一下s的包含t的非连续子串中到达那个位置,然后这个字符串两边的长度相乘就是当前位置开始,满足条件的字符位置.然后我们在找从上一次找到首字母位置下一个开始, 继续往下找就可以了. AC代码: #include<bit…