struct KSD{
priority_queue<node> q1, q2;
void push(node x){
q1.push(x);
}
void del(node x){
q2.push(x);
}
void doit(){
while(!q2.empty() && q1.top()==q2.top()){
q1.pop();
q2.pop();
}
}
bool empty(){
doit();
return q1.empty();
}
node top(){
doit();
return q1.top();
}
};
struct KSD2{
multiset<node> st;
void push(node x){
st.insert(x);
}
void del(node x){
st.erase(st.find(x));
}
bool empty(){
return st.empty();
}
node top(){
return *(st.begin());
}
};
前面一种可以,后面一种不行,为什么?