AC自动机
序列自动机
模板
查找主串中的子序列
1 | #include<bits/stdc++.h> |
Manacher
模板
1 | char s[maxn << 1] = "##"; |
链表
https://leetcode.cn/problems/remove-nth-node-from-end-of-list/
使用快慢指针,让nxt指针先向后移动N次
这样nxt指针和pre指针之间的间隔则为N
然后,nxt和pre同时向后移动,当nxt移动到链表的尾部,pre依然和它间隔为N,那么此时的pre就是链表的倒数第N个节点了
1 | /** |
树
- 基环树
- DFS树
线段树
模板
1 | struct SegTree { |
Hash
模板
1 | struct Hash() { |
Record
一些题目的记录
其他
暂未分类的题目
动态规划
一些DP题目存档
最短路
dijkstra 基于贪心思想,利用了三角不等式,因为全局最小值不可能再被其他节点更新
dijkstra 用于解决单源最短路问题
disjstra 用于解决非负权图问题
1 | #include<bits/stdc++.h> |
优先队列
1 | priority_queue<int,vector<int>,greater<int> >q;//小顶堆 |
语法问题
一些C++的语法问题
最近公共祖先
code
1 | #include<bits/stdc++.h> |
笛卡尔树
例题
Equivalent Prefixes-前缀笛卡尔树
序列u,v 对于[1,ans]上所有的[L,R](1<=L<=R<=ans<=n)
都满足RMQ(u,L,R)=RMQ(v,L,R)
求max(ans);
分析:考虑判断两个序列的前缀笛卡尔树是否相等
注意,如果前缀笛卡尔树相等,则可以判断每一个栈深都相同,想想为什么?、
1 | #include <bits/stdc++.h> |
树形DP
树形DP
Tree painting
1 | #include <bits/stdc++.h> |
树状数组
bitset
1 | #include<bits/stdc++.h> |
KMP
最小生成树
模板
1 | #include<bits/stdc++.h> |