結果

問題 No.2195 AND Set
ユーザー 👑 potato167
提出日時 2023-01-21 02:19:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 489 ms / 2,000 ms
コード長 636 bytes
コンパイル時間 2,438 ms
コンパイル使用メモリ 200,576 KB
最終ジャッジ日時 2025-02-10 06:05:13
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
using ll = long long;
#define all(p) p.begin(),p.end()

int main(){
	int Q;
	cin>>Q;
	set<int> s;
	int M=30;
	vector<int> p(M);
	rep(i,0,Q){
		int t;
		cin>>t;
		if(t==1){
			int a;
			cin>>a;
			if(s.insert(a).second){
				rep(j,0,M){
					if((a&(1<<j))==0) p[j]++;
				}
			}
		}
		if(t==2){
			int a;
			cin>>a;
			if(s.count(a)){
				s.erase(a);
				rep(j,0,M){
					if((a&(1<<j))==0) p[j]--;
				}
			}
		}
		if(t==3){
			int ans=0;
			rep(j,0,M){
				if(p[j]==0) ans+=(1<<j);
			}
			if(s.empty()) cout<<"-1\n";
			else cout<<ans<<"\n";
		}
	}
}
0