ans
wangruihao
2024-01-13 14:50:05
4
返回题目
#include<bits/stdc++.h>
using namespace std;
priority_queue<int,vector<int>,greater<int> > q;//记录第k大的数
priority_queue<int> ql;//存放其它数
int n,k,p;
int main(){
cin>>n>>k>>p;
int siz=0,lst=0;
for(int i=1;i<=n;i++){
int opt;
cin>>opt;
if(opt==1){
int x;
cin>>x;
if(p==1) x=x^lst;
q.push(x);
if(q.size()>k){
int s=q.top();
q.pop(),ql.push(s);
}
}
else{
lst=q.top(),q.pop();
cout<<lst<<"\n";
if(!ql.empty()){
int s=ql.top();
q.push(s),ql.pop();
}
}
}
return 0;
}
{{ vote && vote.total.up }}