結果

問題 No.2195 AND Set
ユーザー ああいいああいい
提出日時 2023-01-21 14:27:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 732 ms / 2,000 ms
コード長 781 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 87,404 KB
最終ジャッジ日時 2024-06-23 22:35:40
合計ジャッジ時間 10,662 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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