String HDU 5672(双指针)】的更多相关文章

String HDU 5672(双指针) 传送门 题意:一个字符串中找到所有拥有不少于k个不同的字符的子串. import java.io.*; import java.util.*; public class Main { static final int N = 1000005; static final int inf= 0x3f3f3f3f; static final double eps= 1e-5; static int vis[]=new int[27]; static char…
Combine String HDU - 5707 题目大意:给你三个串a,b,c,问a和b是不是恰好能组成c,也就是a,b是不是c的两个互补的子序列. 根据题意就可以知道对于c的第一个就应该是a第一个或者b的第一个,如果第一个是a的第一个,那么c的第二个就应该是a的第二个或者是b的第一个,反之也是一样的.那么我们定义dp[i][j]就是a串匹配到i位置,b串匹配到j位置的合理性,那么dp[i][j]就由dp[i-1][j]和dp[i][j-1]推过来,a串匹配到i位置,b串匹配到j位置,那么c…
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5672 bc(中文):http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=692&pid=1002 题解: 对于每一个st(0<=st<len),求最小的ed使得str[st...ed]子串刚好包含k个不同的字母,然后累加起来就行了,由于st,ed都是单调不减的,时间复杂度为O(n+n)=O(n)…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5672 题意: 有一个10≤长度≤1,000,000的字符串,仅由小写字母构成.求有多少个子串,包含有至少k(1≤k≤26)个不同的字母? 分析: 很典型的尺取法. 不断依次移动区间的头尾,使区间满足条件,并找到这样的区间个数. 注意说的是包含至少k个,所以只要找到正好包含k个的区间,然后加上包含后面的串的个数就好了. 代码: #include<cstdio> #include<cstrin…
String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description There is a string S.S only contain lower case English character.(10≤length(S)≤1,000,000)How many substrings there are that contain at least…
String Problem Description There is a string S.S only contain lower case English character.(10≤length(S)≤1,000,000)How many substrings there are that contain at least k(1≤k≤26) distinct characters?   Input There are multiple test cases. The first lin…
<题目链接> 题目大意:给定一个只由26个小写字母组成的字符串,现在问你至少包含k个不同字母的连续子序列总数有多少. 解题分析:经仔细研究,我们发现,每次尺取到符合要求的最小区间,然后将区间的右端点一直移动到字符串的末尾,右端点每移动一位,又能组成一个符合条件的字符串序列,并且,因为每次尺取的过程中,左指针会不断向右移动一位,所以这样的求解能够是的最终的答案不重不漏. #include <bits/stdc++.h> using namespace std; )]; ]; inli…
http://acm.hdu.edu.cn/showproblem.php?pid=3336 Count the string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6672    Accepted Submission(s): 3089 Problem Description It is well known that Aek…
链接: http://acm.hdu.edu.cn/showproblem.php?pid=5311 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1462    Accepted Submission(s): 521 Problem Description Today is the 1st anniversary of BestC…
Fibonacci String Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5008    Accepted Submission(s): 1690 Problem Description After little Jim learned Fibonacci Number in the class , he was very int…