結果

問題 No.2195 AND Set
ユーザー norikamenorikame
提出日時 2023-01-21 02:07:15
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 451 ms / 2,000 ms
コード長 1,018 bytes
コンパイル時間 5,993 ms
コンパイル使用メモリ 310,968 KB
実行使用メモリ 8,136 KB
最終ジャッジ日時 2023-09-05 18:09:37
合計ジャッジ時間 12,177 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 299 ms
4,352 KB
testcase_03 AC 343 ms
4,924 KB
testcase_04 AC 302 ms
4,356 KB
testcase_05 AC 374 ms
4,880 KB
testcase_06 AC 373 ms
4,936 KB
testcase_07 AC 327 ms
4,356 KB
testcase_08 AC 378 ms
4,872 KB
testcase_09 AC 316 ms
4,352 KB
testcase_10 AC 451 ms
7,992 KB
testcase_11 AC 438 ms
8,040 KB
testcase_12 AC 445 ms
8,136 KB
testcase_13 AC 444 ms
8,048 KB
testcase_14 AC 438 ms
8,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

const int INF = (int)(1e9);

int main() {
	int q;
	cin >> q;
	set<int> s;
	vector<int> bcnt(30);
	rep(i1, q) {
		int qi;
		cin >> qi;
		if (qi == 1) {
			int xi;
			cin >> xi;
			if (s.find(xi) != s.end()) continue;
			s.insert(xi);
			rep(i, 30) if (xi&(1<<i)) bcnt[i]++;
		}
		else if (qi == 2) {
			int xi;
			cin >> xi;
			if (s.find(xi) == s.end()) continue;
			s.erase(xi);
			rep(i, 30) if (xi&(1<<i)) bcnt[i]--;
		}
		else {
			int slen = s.size();
			if (slen == 0) cout << -1 << endl;
			else {
				int res = 0;
				rep(i, 30) if (bcnt[i] == slen) res |= 1<<i;
				cout << res << endl;
			}
		}
	}
	return 0;
}
0