結果

問題 No.2195 AND Set
ユーザー ああいいああいい
提出日時 2023-01-21 14:27:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 724 ms / 2,000 ms
コード長 781 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 86,988 KB
実行使用メモリ 90,696 KB
最終ジャッジ日時 2023-09-06 03:45:25
合計ジャッジ時間 12,599 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,220 KB
testcase_01 AC 67 ms
71,088 KB
testcase_02 AC 567 ms
81,100 KB
testcase_03 AC 650 ms
84,272 KB
testcase_04 AC 591 ms
83,944 KB
testcase_05 AC 711 ms
84,444 KB
testcase_06 AC 704 ms
85,060 KB
testcase_07 AC 658 ms
82,276 KB
testcase_08 AC 696 ms
84,884 KB
testcase_09 AC 593 ms
79,712 KB
testcase_10 AC 723 ms
89,752 KB
testcase_11 AC 724 ms
89,760 KB
testcase_12 AC 707 ms
90,696 KB
testcase_13 AC 707 ms
89,596 KB
testcase_14 AC 712 ms
90,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Q = int(input())

s = set()
num = 0
C = 30
dat = [0] * C

for _ in range(Q):
    l = list(map(int,input().split()))
    if l[0] == 1:
        x = l[1]
        if x not in s:
            s.add(x)
            num += 1
            for i in range(C):
                mask = 1 << i
                if x & mask:
                    dat[i] += 1
    elif l[0] == 2:
        x = l[1]
        if x in s:
            num -= 1
            s.remove(x)
            for i in range(C):
                mask = 1 << i
                if x & mask:
                    dat[i] -= 1
    else:
        if num == 0:
            print(-1)
            continue
        ans = 0
        for i in range(C):
            mask = 1 << i
            if dat[i] == num:
                ans |= mask
        print(ans)
0