結果

問題 No.2195 AND Set
ユーザー daiotadaiota
提出日時 2023-01-21 02:45:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 306 ms / 2,000 ms
コード長 691 bytes
コンパイル時間 2,812 ms
コンパイル使用メモリ 171,784 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2023-09-05 18:41:22
合計ジャッジ時間 6,307 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 172 ms
4,376 KB
testcase_03 AC 202 ms
5,036 KB
testcase_04 AC 172 ms
4,380 KB
testcase_05 AC 252 ms
4,980 KB
testcase_06 AC 254 ms
4,964 KB
testcase_07 AC 210 ms
4,380 KB
testcase_08 AC 252 ms
4,892 KB
testcase_09 AC 202 ms
4,376 KB
testcase_10 AC 299 ms
8,008 KB
testcase_11 AC 306 ms
8,000 KB
testcase_12 AC 298 ms
8,000 KB
testcase_13 AC 303 ms
8,192 KB
testcase_14 AC 302 ms
8,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i=0;i<int(n);i++)

int b[35];

int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);


	int Q;
	cin >> Q;
	set<int> s;
	REP(j,Q){
		int q,x;
		cin >> q;

		if(q==1){
			cin >> x;
			if(s.count(x)==1) continue;
			REP(i,31) if(x & (1<<i)) b[i]++;
			s.insert(x);
	    }
		if(q==2 ){
			cin >> x;
			if(s.count(x)==0) continue;
			REP(i,31) if(x & (1<<i)) b[i]--;
			s.erase(x);
		}
		if(q==3){
			int n=s.size(),a=0;
			if(n==0){;
				cout << -1 << endl;
				continue;
			}
			REP(i,31) if(b[i]==n) a+=(1<<i);
			cout << a << endl;
		}

	}



	return 0;
}
0