結果

問題 No.2195 AND Set
ユーザー 沙耶花沙耶花
提出日時 2023-01-20 21:23:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 447 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 5,036 ms
コンパイル使用メモリ 263,324 KB
実行使用メモリ 8,164 KB
最終ジャッジ日時 2023-09-05 13:30:40
合計ジャッジ時間 10,947 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 301 ms
4,376 KB
testcase_03 AC 333 ms
5,084 KB
testcase_04 AC 300 ms
4,376 KB
testcase_05 AC 375 ms
5,120 KB
testcase_06 AC 374 ms
4,972 KB
testcase_07 AC 329 ms
4,376 KB
testcase_08 AC 372 ms
4,972 KB
testcase_09 AC 317 ms
4,376 KB
testcase_10 AC 437 ms
8,024 KB
testcase_11 AC 434 ms
8,136 KB
testcase_12 AC 429 ms
8,140 KB
testcase_13 AC 447 ms
8,076 KB
testcase_14 AC 435 ms
8,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001



int main(){
	
	int q;
	cin>>q;
	
	vector<int> c(30,0);
	set<int> S;
	
	rep(_,q){
		int t;
		cin>>t;
		if(t==1){
			int x;
			cin>>x;
			if(S.count(x))continue;
			S.insert(x);
			rep(j,30){
				if((x>>j)&1)c[j]++;
			}
		}
		if(t==2){
			int x;
			cin>>x;
			if(!S.count(x))continue;
			S.erase(x);
			rep(j,30){
				if((x>>j)&1)c[j]--;
			}
		}
		if(t==3){
			int ans = 0;
			if(S.size()==0)ans = -1;
			else{
				rep(j,30){
					if(c[j]==S.size())ans |= 1<<j;
				}
			}
			cout<<ans<<endl;
		}
	}
	
	return 0;
}
0