結果

問題 No.2195 AND Set
ユーザー lloyzlloyz
提出日時 2023-01-20 21:31:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 741 ms / 2,000 ms
コード長 698 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 91,784 KB
最終ジャッジ日時 2023-09-05 13:41:59
合計ジャッジ時間 10,724 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,476 KB
testcase_01 AC 77 ms
71,304 KB
testcase_02 AC 626 ms
82,168 KB
testcase_03 AC 668 ms
85,728 KB
testcase_04 AC 623 ms
83,692 KB
testcase_05 AC 708 ms
82,908 KB
testcase_06 AC 741 ms
83,896 KB
testcase_07 AC 663 ms
81,124 KB
testcase_08 AC 722 ms
83,140 KB
testcase_09 AC 625 ms
81,236 KB
testcase_10 AC 686 ms
90,596 KB
testcase_11 AC 695 ms
89,172 KB
testcase_12 AC 680 ms
91,784 KB
testcase_13 AC 693 ms
91,288 KB
testcase_14 AC 689 ms
89,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

q = int(input())
res = 1 << 30
seen = set()
D = [0 for _ in range(30)]
for _ in range(q):
    L = list(map(int, input().split()))
    if L[0] == 1:
        x = L[1]
        if x not in seen:
            seen.add(x)
            for i in range(30):
                D[i] += x % 2
                x //= 2
    elif L[0] == 2:
        x = L[1]
        if x in seen:
            seen.remove(x)
            for i in range(30):
                D[i] -= x % 2
                x //= 2
    else:
        if len(seen) == 0:
            print(-1)
            continue
        ans = 0
        num = len(seen)
        for i in range(30):
            if D[i] == num:
                ans += 1 << i
        print(ans)
0