結果

問題 No.2195 AND Set
ユーザー ohanaohana
提出日時 2023-10-23 17:10:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 747 ms / 2,000 ms
コード長 690 bytes
コンパイル時間 927 ms
コンパイル使用メモリ 81,824 KB
実行使用メモリ 87,620 KB
最終ジャッジ日時 2023-10-23 17:10:50
合計ジャッジ時間 13,666 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,572 KB
testcase_01 AC 34 ms
53,572 KB
testcase_02 AC 575 ms
79,032 KB
testcase_03 AC 600 ms
81,504 KB
testcase_04 AC 613 ms
80,416 KB
testcase_05 AC 699 ms
81,412 KB
testcase_06 AC 747 ms
81,616 KB
testcase_07 AC 635 ms
78,248 KB
testcase_08 AC 702 ms
81,272 KB
testcase_09 AC 655 ms
78,820 KB
testcase_10 AC 682 ms
86,864 KB
testcase_11 AC 686 ms
87,212 KB
testcase_12 AC 640 ms
87,128 KB
testcase_13 AC 684 ms
87,620 KB
testcase_14 AC 642 ms
87,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = set()
B = [0 for i in range(31)]
q = int(input())
for i in range(q):
    L = list(map(int, input().split()))
    if L[0] == 1:
        if not (a := L[1]) in S:
            S.add(a)
            cnt = 0
            while a:
                B[cnt] += a % 2
                a //= 2
                cnt += 1

    elif L[0] == 2:
        if (a := L[1]) in S:
            S.discard(a)
            cnt = 0
            while a:
                B[cnt] -= a % 2
                a //= 2
                cnt += 1
    else:
        ret = 0
        for i in range(len(B)):
            if B[i] == len(S):
                ret += 2**i
        #        print("#", end=" ")
        print(ret if S else -1)
0