堆模板
来源:互联网 发布:amos软件 编辑:程序博客网 时间:2024/04/29 06:36
void swap(int &x,int &y){int z=x;x=y;y=z;}struct small_root_heap{ int heap[M],top; void insert(int x){heap[++top]=x;int t=top;while(t>1&&heap[t]<heap[t>>1])swap(heap[t],heap[t>>1]),t>>=1;} void pop() { int t=2; heap[1]=heap[top];heap[top--]=0; while(t<=top) { if(heap[t]>heap[t+1]&&t<top)t++; if(heap[t]<heap[t>>1])swap(heap[t],heap[t>>1]),t<<=1; else break; } }};struct big_root_heap{ int heap[M],top; void insert(int x){heap[++top]=x;int t=top;while(t>1&&heap[t]>heap[t>>1])swap(heap[t],heap[t>>1]),t>>=1;} void pop() { int t=2; heap[1]=heap[top];heap[top--]=0; while(t<=top) { if(heap[t]<heap[t+1]&&t<top)t++; if(heap[t]>heap[t>>1])swap(heap[t],heap[t>>1]),t<<=1; else break; } }};
0 0
- 堆模板
- 堆模板
- 堆模板
- 堆模板
- 堆模板
- [模板]堆
- 【模板】堆
- 堆模板
- 堆模板
- 堆【模板】
- 【ACM模板】堆排序
- 堆排序模板
- C++堆排序模板
- 堆排序【模板】
- 堆排序模板
- 堆排序模板
- c++模板---堆
- C++模板堆排序
- uva10085(The Most Distant State)-隐式图搜索
- 必备神器--Google
- 关于socket
- 关于《Swift开发指南》背后的那些事
- 在美国读硕士MASTER和读博士PHD,学习方面最大的区别是什么
- 堆模板
- java设计模式
- UVA10282
- java爱听音乐音乐播放器
- lable设置
- C语言中switch case的类型比较机制
- 黑马程序员—[JavaEE就业薪资] 云计算8期,毕业22个工作日,就业率83.02%,平均薪资8110元
- 格子游戏
- 单调队列模板