結果

問題 No.2195 AND Set
コンテスト
ユーザー lllllll88938494
提出日時 2023-02-19 07:03:33
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 747 ms / 2,000 ms
コード長 1,053 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 727 ms
コンパイル使用メモリ 85,376 KB
実行使用メモリ 197,464 KB
最終ジャッジ日時 2026-04-02 22:55:49
合計ジャッジ時間 9,485 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

x = int(input())
a = [{1:0,0:0} for i in range(32)]
s = set()
for i in range(x):
    t =list(map(int,input().split()))
    if t[0] == 1:
        if t[1] in s:
            continue
        else:
            s.add(t[1])
            b=bin(t[1])
            for i in range(31,-1,-1):
                if  i >= len(b)-2:
                    a[i][0] += 1
                    continue
                a[i][int(b[~i])] += 1
                
    elif t[0] == 2:
        if t[1] not in s:
            continue
        else:
            s.discard(t[1])
            b=bin(t[1])
            for i in range(31,-1,-1):
                if  i >= len(b)-2:
                    a[i][0] -= 1
                    continue
                a[i][int(b[~i])] -= 1
                
    else:
        if len(s) == 0:
            print(-1)
            continue
        aa=0
        for i in range(31):
            if a[i][1] >= 1 and a[i][0] == 0:
                aa += pow(2,i)
        print(aa)
            
            
            
            
                
                
0