結果

問題 No.2195 AND Set
ユーザー lllllll88938494lllllll88938494
提出日時 2023-02-19 07:03:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,059 ms / 2,000 ms
コード長 1,053 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 87,000 KB
実行使用メモリ 96,532 KB
最終ジャッジ日時 2023-09-27 15:43:10
合計ジャッジ時間 13,638 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,164 KB
testcase_01 AC 66 ms
71,128 KB
testcase_02 AC 693 ms
82,736 KB
testcase_03 AC 759 ms
85,760 KB
testcase_04 AC 653 ms
83,300 KB
testcase_05 AC 829 ms
84,400 KB
testcase_06 AC 900 ms
85,636 KB
testcase_07 AC 728 ms
81,488 KB
testcase_08 AC 859 ms
85,344 KB
testcase_09 AC 667 ms
80,968 KB
testcase_10 AC 1,050 ms
94,676 KB
testcase_11 AC 1,050 ms
95,072 KB
testcase_12 AC 1,026 ms
96,452 KB
testcase_13 AC 1,059 ms
96,052 KB
testcase_14 AC 1,041 ms
96,532 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=0
        for i in range(31):
            if a[i][1] >= 1 and a[i][0] == 0:
                aa += pow(2,i)
        print(aa)
            
            
            
            
                
                
0