08 2019 档案

摘要:题意 给定一个长度为 $n$ 的字符串,有 $q$ 次询问,每次询问求字符串的 $[l, r]$ 所形成的子串第 $k$ 次出现时的位置。 "传送门" 思路 $[l, r]$ 形成的子串,它是一些后缀的前缀,并且这些前缀在后缀数组中的rk是相邻的,因此,对于$[l, r]$ 我们可以通过 rmq/l 阅读全文
posted @ 2019-08-25 22:26 Acerkoo 阅读(166) 评论(0) 推荐(0)
摘要:题意 后缀数组板子题 "传送门" Code cpp include using namespace std; const int maxn = 1e6+10; int n; char str[maxn]; struct SuffixArray { int x[maxn], y[maxn], c[ma 阅读全文
posted @ 2019-08-24 22:24 Acerkoo 阅读(128) 评论(0) 推荐(0)
摘要:题意 给定n个模式串,求目标串中出现了多少个模式串。 "传送门" 思路 AC自动机模版题。 Code cpp include using namespace std; const int maxn = 1e6+10; struct Ac { int tr[maxn][26], fail[maxn], 阅读全文
posted @ 2019-08-22 23:15 Acerkoo 阅读(115) 评论(0) 推荐(0)
摘要:题意 有一个大小为 $n ,(n \leq 3e5)$ 的序列,序列中的每一个数 $a_i$ 满足$1 \leq a_i \leq n$, 现定义 good subarray:对于一段区间$a_l, a_{l+1}, \dots, a_r$,满足区间内无重复元素并且 $\max\{a_l, a_{l 阅读全文
posted @ 2019-08-22 23:07 Acerkoo 阅读(205) 评论(0) 推荐(0)
摘要:题意 给出大小为 $n$ 的字符串集合,给定字符串 $t$ ,求拆分 $t$ 的方案数,要求串 $t$ 拆分后每一个串都要是集合中的某个串。 _答案取模1e9+7_ 思路 对于一个串 $t$ 的第i个位置,如果他是某个串的结尾, 并且这个串之前的串也是个合法串,那么可进行dp转移,可用ac自动机的f 阅读全文
posted @ 2019-08-21 00:54 Acerkoo 阅读(223) 评论(0) 推荐(0)
摘要:题意 给定一个串,求各长度下,本质不同的回文串并且回文串的左右两个字串也是回文串的数量。 "传送门" 思路 题意比较绕,理顺下来就是在回文树的每个节点,求其节点对应回文串的一半是否也是回文串,如果是,则其对该节点的长度产生贡献, 判断其回文串的一半是否也为回文串可以用马拉车或者哈希,哈希相对好写一点 阅读全文
posted @ 2019-08-20 10:58 Acerkoo 阅读(187) 评论(0) 推荐(0)
摘要:链接:https://ac.nowcoder.com/acm/contest/888/A来源:牛客网 题目描述 Gromah and LZR entered the great tomb, the first thing they see is a matrix of size n×mn\times 阅读全文
posted @ 2019-08-11 12:57 Acerkoo 阅读(213) 评论(0) 推荐(0)
摘要:题意 对于一个非负整数 i, 当 $i + (i+1) + (i+2)$ 计算过程中不产生进位时,称i满足条件, 求 小于n的 i 的个数。 "传送门" 思路 数位dp。 Code cpp include using namespace std; typedef long long ll; ll d 阅读全文
posted @ 2019-08-09 00:01 Acerkoo 阅读(141) 评论(0) 推荐(0)
摘要:题意 AC自动机模版题。 "传送门" Code cpp include using namespace std; const int maxn = 1e6+10; int fail[maxn], e[maxn], tree[maxn][26], tot; void insert(char t) { 阅读全文
posted @ 2019-08-08 23:43 Acerkoo 阅读(117) 评论(0) 推荐(0)
摘要:题意 给定一个字符串,求其子串,该子串即是前缀又是后缀,也是既非前缀也非后缀的字串。 "传送门" 思路 前缀数组的灵活应用,对于即使后缀也是前缀的子串,判断是否在之前出现过即可。 Code cpp include using namespace std; const int maxn = 1e6+1 阅读全文
posted @ 2019-08-06 10:42 Acerkoo 阅读(170) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-08-05 23:31 Acerkoo 阅读(174) 评论(0) 推荐(0)
摘要:题意 给定两个长度为1e5的数组a、b,在对a、b数组分别重新排序后,求相同长度的数组c,使得c[i]=a[i] xor b[i],使得数组 c 的字典序最小。 思路 分别对a、b建字典树,能走$11/00$就走,否则就走$01/10$,找出最小的n个数,从小到大排序之后即为所求数组。 Code c 阅读全文
posted @ 2019-08-05 20:52 Acerkoo 阅读(252) 评论(0) 推荐(0)
摘要:题意 对于大小为n的正整数数组a,有q次询问,每次询问给出整数数p、k,要求输出离p第k近的数字,强制在线。 思路 主席树维护区间 $[l, r]$ 数字出现次数,二分答案。 Code 阅读全文
posted @ 2019-08-05 20:29 Acerkoo 阅读(166) 评论(0) 推荐(0)
摘要:题意 对一个有1e5个点,点权初值为0的树上进行4种操作: 1、结点u到结点v上的所有点权乘x。 2、结点u到结点v上所有的点权加x。 3、结点u到结点v上所有的点权取非。 4、结点u到结点v路径上点权的和。 _答案模$2^{64}$_ 思路 对操作1、2树链剖分加线段树维护即可,对操作3,取非操作 阅读全文
posted @ 2019-08-03 18:27 Acerkoo 阅读(225) 评论(0) 推荐(0)