藤藤的队列

jiaoyuyuan 2024-01-13 16:28:59 1 返回题目

#include<bits/stdc++.h>

using namespace std;

int n,k,p,i,op,x,last;

priority_queue<int,vector, greater >q1;

priority_queueq2;

int main(){

cin>>n>>k>>p;
for(i=1;i<=n;i++){
	cin>>op;
	if(op==1){
		cin>>x;
		if(p==1)
			x=x^last;
		q1.push(x);
		if(q1.size()>k){
			int t=q1.top();
			q1.pop();
			q2.push(t);
		}
	}
	else{
		last=q1.top();q1.pop();
		if(!q2.empty()){
			int t=q2.top();
			q1.push(t);
			q2.pop();
		}
		cout<<last<<'\n';
	}
}
return 0;

}

{{ vote && vote.total.up }}