优先队列,但是带修(?)
起因:
教授在贺题解时无意看到了这个相当天才的发明,于是写了一个自己的版本并推而广之。
代码:
struct cpq_int//changeable priority_queue
{
priority_queue<int>add,del;
void push(int x)
{
add.push(x);
}
void pop(int x)
{
del.push(x);
}
int top()
{
while(!add.empty()&&!del.empty())
{
if(add.top()!=del.top())
{
return add.top();
}
add.pop();
del.pop();
}
if(add.empty())
{
return -0x3f3f3f3f;
}
return add.top();
}
}
浙公网安备 33010602011771号