struct heap {//手写实现删除任意位置数值的堆
priority_queue<int> A , B;
void push(int x) {
A.push(x);
}
void erase(int x) {
B.push(x);
}
void pop() {
while(B.size() && A.top() == B.top()) A.pop(), B.pop();
A.pop();
}
int top() {
while(B.size() && A.top() == B.top()) A.pop(), B.pop();
if(!A.size()) return 0;
return A.top();
}
int size() {
return A.size() - B,size();
}
int stop() {
if(size() < 2) return 0;
int x = top(); pop();
int y = top(); push(x);
return y;
}
} ALL, First[110000], Second[110000];
04-03
972
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交