Good Substrings CodeForces - 271D】的更多相关文章

You've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad. A substring s[l...r] (1 ≤ l ≤ r ≤ |s|) of string s  =  s1s2...s|s| (where|s| is the length of string s) is string  slsl + 1...sr. The su…
传送门 D. Good Substrings time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output You've got string s, consisting of small English letters. Some of the English letters are good, the rest are bad. A s…
原题链接:http://codeforces.com/problemset/problem/271/D 题目原文: D. Good Substrings time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output You've got string s, consisting of small English letters. Some…
[链接] 我是链接,点我呀:) [题意] [题解] 字典树 我们可以两重循环(i,j) 来枚举所有的子串 即i=1,j=1,2,3... i=2,j = 2,3,4,.. 于是我们在i变化的时候(就是j层循环完了,i要执行i+1的时候 令cur=字典树的root 然后沿着字典树往下走. 遇到没有走过的位置,就说明我们找到了一个之前没有碰到的子串. 那么我们就++tot,按照字典树的规则,创建一个新的节点. 否则如果有这个节点,那么就接着往下走就好,说明这个子串s[i..j]之前出现过 然后如果特…
题目大意 题目看样例也能猜到就是输出最短的循环串. 吐槽 明明是div3第一题为啥子还会用到kmp的知识? 解法 这个题仔细看发现是求最长可去除的后缀,也就是说去除跟下一个相同的字符串还能连接起来.这个不就是next数组的功能吗?最长公共前后缀. 公式:len-next[len] 我们把前k-1个字符串只输出前面的部分最后加上一个完整的字符串即可 完整代码 #include <bits/stdc++.h> using namespace std; char a[500]; int nex[50…
大意: 给定字符串$s$, 长度为$n$, 取$k=\lfloor log2(n)\rfloor$, 第$i$次操作删除一个长度为$2^{i-1}$的子串, 求一种方案使得, $k$次操作后$s$的字典序最小, 输出删除后的字符串. 考虑一些弱化的情况, 每次均删除长为$2$的子串, 共删除$k$次 那么很容易得出$O(n^3)$的$DP$. int n, k; string s, dp[N][N]; int main() { cin>>s>>k; n = s.size(); RE…
Good Substrings CodeForces - 271D 给你一个只包含小写字母的字符串s.问你在这个字符串中有多少个不同的子串.且要求这些子串中不得出现超过k个的特殊字母.*子串s1和子串s2不同,当且仅当s1!=s2,即s1和s2完全不同.*子串指的是字符串中截取出来的连续的一段.输入格式第一行,一个长度不超过1500仅包含小写字母的字符串s.第二行,包含一个长度为26的01字符串,如果字符串的第i(0<=i< length(s))个位置为'0',说明'a'+i为特殊字母,否则'…
A. Two Substrings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/problem/A Description You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "…
B. Substrings Sort time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given nn strings. Each string consists of lowercase English letters. Rearrange (reorder) the given strings in such…
D. Count Good Substrings 题目连接: http://codeforces.com/contest/451/problem/D Description We call a string good, if after merging all the consecutive equal characters, the resulting string is palindrome. For example, "aabba" is good, because after…