Codeforces 710F String Set Quries】的更多相关文章

题意 维护一个字符串的集合\(D\), 支持3种操作: 插入一个字符串\(s\) 删除一个字符串\(s\) 查询一个字符串\(s\)在\(D\)中作为子串出现的次数 强制在线 解法 AC自动机+二进制分组 二进制分组 二进制分组是一种用 (套用) 离线方法解决要求强制在线问题的分块技巧. 我第一次见到它是在2013年IOI国家集训队许昊然的论文中. 满足修改操作对询问的贡献独立, 修改操作之间互不影响效果 (其实前后两句说的是同一件事) 的数据结构题, 都可以采用二进制分组算法. 原理 对修改操…
题面传送门 题意:强制在线的 AC 自动机. \(n,\sum|s|\leq 3\times 10^5\) 如果不是强制在线那此题就是道 sb 题,加了强制在线就不那么 sb 了. 这里介绍两种做法: 根号分治 考虑到 KMP 擅长处理单个字符串匹配的情况,但对于多模式串的情况复杂度就不那么优秀了. 而 AC 自动机擅长处理多模式串匹配的情况,但预处理复杂度是线性的,每加进来一个字符串都预处理一遍复杂度显然吃不消. 考虑将二者结合,设一个临界值 \(B\),每 \(B\) 个串建一个 AC 自动…
Codeforces 710 F 思路:KMP学的还是不过关啊... 按照字符串的长度分类,如果长度大于\(\sqrt{n}\)的就扔到什么地方等待查询,否则就扔进trie里面. 对于查询,我们先在trie树中暴力找有多少出现过的子串,因为trie中长度不超过\(\sqrt{n}\),那么这个操作总共不会超过\(n\sqrt{n}\)次. 然后对于每一个长度大于\(\sqrt{n}\)的,把kmp的fail数组构造出来,暴力在待查询串中查询出现次数.因为长度大于\(\sqrt{n}\)的不会超过…
ou should process m queries over a set D of strings. Each query is one of three kinds: Add a string s to the set D. It is guaranteed that the string s was not added before. Delete a string s from the set D. It is guaranteed that the string s is in th…
题目链接:http://codeforces.com/contest/710/problem/F 题意:维护一个集合,集合要求满足三种操作. 1 str:向集合插入字符串str(保证不会插入之前已经插入过的字符串) 2str:从集合中删除字符串str(保证删除的str一定在集合中) 3 str:str的子串有多少个在集合中出现过. 思路:题目意思就是一个可以插入/删除/查询的AC自动机.但是如果我们暴力求解,每次添加/删除一个字符串到自动机中求从前求一边适配指针的话会TLE.所以我们考虑用其他方…
D. String Game time limit per test:2 seconds memory limit per test:512 megabytes input:standard input output:standard output Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty…
题目链接:http://codeforces.com/contest/828/problem/C C. String Reconstruction time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Ivan had string s consisting of small English letters. However, hi…
String Manipulation 1.0 Time Limit: 3000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 159C64-bit integer IO format: %I64d      Java class name: (Any) One popular website developed an unusual username editing proced…
题目链接:http://codeforces.com/problemset/problem/779/D 题意:有两个字符串一个初始串一个目标串,有t次机会删除初始串的字符问最多操作几次后刚好凑不成目标串 所得结果减1 其实简单匹配只需要n只要二分查找一下答案那么结果就是n*logn #include <iostream> #include <cstring> #include <string> using namespace std; const int M = 2e5…
B. Lucky String time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain on…