結果

問題 No.2195 AND Set
ユーザー lllllll88938494
提出日時 2023-02-19 06:57:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,188 ms / 2,000 ms
コード長 1,125 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 93,844 KB
最終ジャッジ日時 2024-07-20 09:50:32
合計ジャッジ時間 15,785 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

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=[]
        for i in range(31):
            if a[i][1] >= 1 and a[i][0] == 0:
                aa.append('1')
            else:
                aa.append('0')
        print(int(''.join(aa[::-1]),2))
            
            
            
            
                
                
0