[HihoCoder1413]Rikka with String】的更多相关文章

题目 哈哈哈哈哈哈哈哈哈哈我还没自闭 好像前后调了两天了 哈哈哈哈哈哈哈哈哈哈我还没自闭 这道题就是给定一个小写字母串,回答分别把每个位置上的字符替换为\(#\)后的本质不同的子串数 首先就是跨过这个特殊字符的字符串出现次数显然都是\(1\),这部分的贡献就直接是\(i\times(n-i+1)\) 之后我们用\(SAM\)搞出所有前缀和所有后缀的本质不同子串个数,这时候答案的贡献就是\(pre_{i-1}+beh_{i+1}\) 显然会算多一些在前缀和后缀里都出现的子串 想个办法把这些东西搞出…
vjudge 题意 给你一个串,问你把每个位置的字符替换成#后串中有多少本质不同的子串. \(n\le 3*10^5\) sol 首先可以计算出原串里面有多少本质不同的子串.显然就是\(\sum_{i=1}^{tot}len_i-len_{fa_i}\). 然后考虑把\(i\)位置替换成了#,那么你从\(1..i\)中任选左端点,\(i..n\)中任选右端点,这样的子串一定会是本质不同的.(一定含有字符#,满足长度不同或#的出现位置不同) 所以对于位置\(i\),答案先加上\(i*(n-i+1)…
[Hihocoder1413]Rikka with String(后缀自动机) 题面 Hihocoder 给定一个小写字母串,回答分别把每个位置上的字符替换为'#'后的本质不同的子串数. 题解 首先横跨'#'左右的串一定恰好只会出现一次,所以直接统计答案. 那么剩下的部分就是左右的本质不同的子串数. 我们把答案拆成三个部分,先是左侧本质不同子串的个数,再是右侧本质不同子串的个数.最后再减去既在左侧出现过,又在右侧出现过的串的个数. 左右两个直接用\(SAM\)算就好了. 在两侧同时出现过的,我们…
Rikka with string Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 581    Accepted Submission(s): 227 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation,…
Rikka with String http://acm.hdu.edu.cn/showproblem.php?pid=6086 题意: 求一个长度为2L的,包含所给定的n的串,并且满足非对称. 分析: AC自动机+状压dp. 首先给这个n个串,建立AC自动机.然后去枚举长度为L的一个串,就可以知道另一半了. 如果给定的串完全存在于左边或者右边,那么直接往AC自动机加入这个串或者取反后的反串.如果是跨越中间,那么暴力的把所有的串,从中间切开,然后判断是否合法,加入到AC自动机上就行,如果长度枚举…
2017 多校5 Rikka with String(ac自动机+dp) 题意: Yuta has \(n\) \(01\) strings \(s_i\), and he wants to know the number of \(01\) antisymmetric strings of length \(2L\) which contain all given strings \(s_i\) as continuous substrings. A \(01\) string \(s\) i…
Rikka with String Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has n 01 strings si, and he wants to know the number of 01 antis…
题目链接 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has n 01 strings si, and he wants to know the number of 01 antisymmetric stri…
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: One day, Yuta got a string which contains n letters but Rikka lost it in accident. Now…
http://acm.hdu.edu.cn/showproblem.php?pid=5202 字符串处理的题,要细心. 给定一个只包含小写字母和问号的字符串,让我们还原出本来的字符串,把问号替换成任意字符,如果有多种可能输出字典序最小的,原字符串不能是回文串. 首先判断有没有非法字符,然后是否包含问号,如果没有包含则判断是否是回文串,满足则表示不能还原 . 否则把所有问号都替换成‘a',但是可能构成回文,然后继续替换,直到不是回文为止. #include <iostream> #include…