J-408之数据结构_北京信息科技大学第十五届程序设计竞赛(同步赛) (nowcoder.com)
思维好题,直接用两个set存没出现的数字就好了
// Problem: 408之数据结构
// Contest: NowCoder
// URL: https://ac.nowcoder.com/acm/contest/68572/J
// Memory Limit: 524288 MB
// Time Limit: 4000 ms
//
// Powered by CP Editor (https://cpeditor.org)#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N = 1e6+10;
int n,q;
set<int>a,b;
void solve()
{cin>>n>>q;for(int i=0;i<N;i++){if(i&1)a.insert(i);else b.insert(i);}int x,mask;for(int i=1;i<=n;i++){cin>>x;if(a.count(x))a.erase(x);if(b.count(x))b.erase(x);}while(q--){int op;cin>>op;if(op==1){cin>>x>>mask;if(mask)a.erase(a.lower_bound(x));else b.erase(b.lower_bound(x));}else{cin>>mask;if(mask)cout<<*(a.begin())<<"\n";else cout<<*(b.begin())<<"\n";}}}int main()
{ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);int _;_ = 1;while(_--)solve();return 0;
}