結果

問題 No.2195 AND Set
ユーザー lllllll88938494lllllll88938494
提出日時 2023-02-19 06:57:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,175 ms / 2,000 ms
コード長 1,125 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 98,704 KB
最終ジャッジ日時 2023-09-27 15:40:07
合計ジャッジ時間 17,377 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,048 KB
testcase_01 AC 72 ms
71,352 KB
testcase_02 AC 693 ms
82,072 KB
testcase_03 AC 861 ms
84,564 KB
testcase_04 AC 737 ms
84,004 KB
testcase_05 AC 904 ms
82,672 KB
testcase_06 AC 996 ms
85,652 KB
testcase_07 AC 787 ms
81,108 KB
testcase_08 AC 973 ms
85,256 KB
testcase_09 AC 748 ms
81,524 KB
testcase_10 AC 1,144 ms
95,124 KB
testcase_11 AC 1,159 ms
96,744 KB
testcase_12 AC 1,137 ms
96,012 KB
testcase_13 AC 1,175 ms
98,704 KB
testcase_14 AC 1,153 ms
94,980 KB
権限があれば一括ダウンロードができます

ソースコード

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