
数据结构
文章平均质量分 81
DASEason
https://github.com/qq547276542
展开
-
2维fenwick树
const int MAXH=107,MAXW=107;struct Fenwick { int W,H; int mat[MAXH][MAXW]; void init(int w,int h){ //初始化矩阵 memset(mat,0,sizeof(mat)); W=w,H=h; } int lowbit(int原创 2015-08-19 15:53:36 · 2044 阅读 · 0 评论 -
线段树模板合集--单点替换,区间替换,区间增加3种情况
单点替换,单点增加,区间求最值,区间求和#include #include #include using namespace std;#define lson l , m , rt << 1#define rson m + 1 , r , rt << 1 | 1const int maxn = 100007;const int INF=0x7fffffff;int MAX[maxn原创 2016-05-30 11:46:38 · 4773 阅读 · 1 评论 -
Size Balanced Tree(SBT)平衡二叉树
const int N = 210005;const int INF=0x7FFFFFFF;struct SBT{ int key,left,right,size;} tree[N];int root,top;void init(){ root=top=0;}/////以下函数x参数带rootvoid left_rot(int &x){ int y原创 2015-12-05 20:30:07 · 2672 阅读 · 0 评论 -
K-d Tree 模板
typedef long long LL;typedef pair PII;typedef pair pii;const int maxn = 1000005; //点的数量const int maxD = 2; //维数,根据题目维数修改此处const int maxM = 12;const LL INF = 4611686018427387903LL;int now;s原创 2015-08-19 16:51:19 · 2292 阅读 · 0 评论 -
RMQ模板
int d[50000][40];vector A;void RMQ_init(const vector & A){ //RMQ 初始化 int n=A.size(); for(int i=0;i<n;i++)d[i][0]=A[i]; for(int j=1;(1<<j)<=n;j++) for(int i=0;i+(1<<j)-1<n;i+原创 2015-08-20 10:28:58 · 1873 阅读 · 0 评论 -
二维线段树(单点更新)
#include #include #include #include #include #include #include using namespace std;const int INF=1<<30;const int maxn=2000+10;struct INtervalTree2D{ //2维线段树x轴y轴的下标均从1开始 int Max[maxn][maxn原创 2015-08-19 16:45:51 · 1858 阅读 · 0 评论 -
AC自动机
#include#include#include#include#includeusing namespace std;const int maxnode=1000007;const int SIGMA_SIZE=26; //若字符串可能出现所有字符,则要将该值改为128,并且将idx函数中“ -‘a’ "去掉//给定多个模板,一个文本,能够找出模板在文本中的位置与附加信息va原创 2015-08-20 09:48:37 · 1875 阅读 · 0 评论 -
线段树(求矩形并,交,并减交的面积)
# define N 100100int e; //记录横坐标个数,注意主函数里不要有同名变量struct node1{ double x,y1,y2; int f;} line[N*2];struct node2{ double rf,lf,cnt,incnt; //求矩形交可以没有cnt,求矩形并可以没有incnt int l,r,c;} tr原创 2015-08-19 16:43:39 · 2027 阅读 · 0 评论 -
字典树模板
const int maxnode=100003;const int sigma_size=26; //字符集大小,注意idx函数也要随着修改struct Trie{ int ch[maxnode][sigma_size]; int val[maxnode]; int sz; void init() { sz=1;memset(ch[0],0,sizeof(c原创 2015-08-19 16:48:54 · 2117 阅读 · 0 评论 -
Hash
const int hashsize = 1000003;const int maxstate = 1000000;typedef int State;int head[hashsize],Next[maxstate];State st[maxstate];//需要定义一个状态数组int id=0;//状态数组的下标,访问状态void init(){memset(head,0,size原创 2015-08-19 16:55:03 · 1909 阅读 · 0 评论 -
线段树(求矩形周长)
# define N 5005int e;struct node1 { int x,y1,y2; int f;} line[2*N];struct node2 { int l,r; int lf,rf;/*左右区间所对应的y值*/ int cnt;/*节点上线段的测度*/ int count;/*节点被线段完全覆盖的次数*/ int原创 2015-08-19 16:34:48 · 2115 阅读 · 0 评论 -
树状数组
const int maxn=10010; //树状数组可能的最大长度struct BIT { //设树状数组为A[],下标从1开始 int N; int C[maxn]; //辅助数组 void init(int BIT_size) { //初始化,BIT_size 为树状数组的长度 N=BIT_size; memset(C,0,s原创 2015-08-19 17:03:41 · 1859 阅读 · 0 评论