题意 给你 \(n\) 个 \(01\) 串 \(S\) ,其中有些位置可能为 \(?\) 表示能任意填 \(0/1\) .问对于所有填法,把所有串插入到 \(Trie\) 的节点数之和(空串看做根节点). \(n \le 20, 1 \le |S_i| \le 50\) 题解 直接算显然不太好算的. \(Trie\) 的节点数其实就是本质不同的前缀个数,可以看做 \(n\) 个串的所有前缀的并集的大小. 我们可以套用容斥原理最初的式子. \[ \left| \bigcup_{i=1}^n A_…
31 Rikka with Parenthesis II (六花与括号II) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Description 题目描述 As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to…
Rikka with Parenthesis II 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5831 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: Correct parenthe…
[Hihocoder1413]Rikka with String(后缀自动机) 题面 Hihocoder 给定一个小写字母串,回答分别把每个位置上的字符替换为'#'后的本质不同的子串数. 题解 首先横跨'#'左右的串一定恰好只会出现一次,所以直接统计答案. 那么剩下的部分就是左右的本质不同的子串数. 我们把答案拆成三个部分,先是左侧本质不同子串的个数,再是右侧本质不同子串的个数.最后再减去既在左侧出现过,又在右侧出现过的串的个数. 左右两个直接用\(SAM\)算就好了. 在两侧同时出现过的,我们…
Rikka with Parenthesis II 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5831 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: Correct parenthe…
Rikka with Parenthesis II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situat…
Rikka with Parenthesis II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 136    Accepted Submission(s): 97 Problem Description As we know, Rikka is poor at math. Yuta is worrying about this sit…
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,…
原题地址: 344 Reverse String: https://leetcode.com/problems/reverse-string/description/ 541 Reverse String II: https://leetcode.com/problems/reverse-string-ii/description/ 题目&&解法: 1.Reverse String: Write a function that takes a string as input and ret…
344. Reverse String 最基础的旋转字符串 class Solution { public: void reverseString(vector<char>& s) { if(s.empty()) return; ; ; while(start < end){ char tmp = s[end]; s[end] = s[start]; s[start] = tmp; start++; end--; } return; } }; 541. Reverse Strin…