![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
一些数据结构
乌克兰大野猪
一只快乐的小菜鸡
展开
-
并查集的实现
//并查集的实现#include<cstdio>#define N 100005int par[N],depth[N];//初始化 void init(int n){ for(int i=0;i<n;i++){ par[i]=i; depth[i]=0; }} int find(int x){ if(par[x]==x) return x; e...原创 2020-02-18 09:45:48 · 60 阅读 · 0 评论 -
二叉搜索树的实现
//二叉搜索树的实现,当然也可以使用set和map实现 #include<cstdio>struct node{ int val; node *lch,*rch;}; //插入操作,先判断是比叶子节点的值大还是小 node *insert(node *p,int x){ if(p==NULL) { node *q=new node; q->val =x;...原创 2020-02-18 09:28:53 · 60 阅读 · 0 评论 -
堆的一种实现方法
堆的一种实现方法//堆的模板#include<cstdio>int h[10005],num;void swap(int x,int y){ int t=h[x]; h[x]=h[y]; h[y]=t;}void pushdown(int i){ int t,flag=0;//节点的编号 while(i*2+1<num&&flag==0)...原创 2020-02-17 20:30:52 · 69 阅读 · 0 评论 -
树状数组模板
#include<cstdio>int a[500005],c[500005],n,m,o,x,y;int lowbit(int m){ return m&(-m);}int getsum(int x){ int ans=0; while(x>0) { ans+=c[x]; x-=lowbit(x); } return ans;}voi...原创 2020-02-15 09:55:22 · 72 阅读 · 0 评论