摘要: /* 本质:Trie的基础上+KMP的思想(失配指针) 匹配过程中,为了防止失败就前功尽弃,不能利用之前匹配结果的情况,就发明了KMP 如果将KMP运用到高效的Trie上,就可以实现多模式串的匹配 每次匹配失败,就去查找具有最长相同前缀的链 例如,对于abchi和chj这两条链,当我们遍历至i,我们 阅读全文
posted @ 2025-10-30 19:12 _CENSORED 阅读(14) 评论(0) 推荐(0)
摘要: 统计对于每个i<j,求a[i]>a[j]的数量 在每一次更新(update)树状数组时,以元素的值作为树状数组的索引,更新的值为 +1,代表个数。 在每一次获取(query)逆序对数时,存在于树状数组中的元素的索引值都比当前元素的大(逆序遍历), 那么自然获取到的树状数组的值即为索引值比当前元素的大 阅读全文
posted @ 2025-10-23 21:40 _CENSORED 阅读(3) 评论(0) 推荐(0)
摘要: #include<iostream> using namespace std; /*本代码模拟的是小根堆*/ const int N = 5e5+1, INF = 0x3f3f3f3f; struct node { int l, r, val, pos, siz, cnt; //val:结点的值,p 阅读全文
posted @ 2025-09-28 20:24 _CENSORED 阅读(11) 评论(0) 推荐(0)
摘要: #include <iostream> #include <tuple> using namespace std; struct node { node *l,*r; int val, pri; int cnt; int siz; node(int _val) { val = _val; siz = 阅读全文
posted @ 2025-09-28 20:24 _CENSORED 阅读(6) 评论(1) 推荐(0)