結果

問題 No.2195 AND Set
ユーザー 👑 potato167potato167
提出日時 2023-01-21 02:19:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 439 ms / 2,000 ms
コード長 636 bytes
コンパイル時間 2,093 ms
コンパイル使用メモリ 206,204 KB
実行使用メモリ 8,048 KB
最終ジャッジ日時 2023-09-05 18:21:03
合計ジャッジ時間 8,455 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 294 ms
4,376 KB
testcase_03 AC 323 ms
4,860 KB
testcase_04 AC 294 ms
4,376 KB
testcase_05 AC 368 ms
4,860 KB
testcase_06 AC 368 ms
4,936 KB
testcase_07 AC 321 ms
4,376 KB
testcase_08 AC 371 ms
4,916 KB
testcase_09 AC 313 ms
4,376 KB
testcase_10 AC 432 ms
8,048 KB
testcase_11 AC 431 ms
8,024 KB
testcase_12 AC 433 ms
8,040 KB
testcase_13 AC 439 ms
8,020 KB
testcase_14 AC 428 ms
8,044 KB
権限があれば一括ダウンロードができます

ソースコード

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