結果

問題 No.2195 AND Set
ユーザー norikamenorikame
提出日時 2023-01-20 22:47:55
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 444 ms / 2,000 ms
コード長 997 bytes
コンパイル時間 5,811 ms
コンパイル使用メモリ 311,072 KB
実行使用メモリ 8,164 KB
最終ジャッジ日時 2023-09-05 15:12:25
合計ジャッジ時間 12,182 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 301 ms
4,380 KB
testcase_03 AC 324 ms
4,968 KB
testcase_04 AC 304 ms
4,376 KB
testcase_05 AC 372 ms
5,084 KB
testcase_06 AC 372 ms
4,972 KB
testcase_07 AC 326 ms
4,376 KB
testcase_08 AC 374 ms
4,900 KB
testcase_09 AC 317 ms
4,376 KB
testcase_10 AC 444 ms
8,036 KB
testcase_11 AC 432 ms
8,144 KB
testcase_12 AC 427 ms
8,164 KB
testcase_13 AC 429 ms
8,004 KB
testcase_14 AC 435 ms
8,028 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> zcnt(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))) zcnt[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))) zcnt[i]--;
		}
		else {
			if (s.empty()) cout << -1 << endl;
			else {
				int res = 0;
				rep(i, 30) if (zcnt[i] == 0) res |= 1<<i;
				cout << res << endl;
			}
		}
	}
	return 0;
}
0