結果

問題 No.2195 AND Set
ユーザー HydruHydru
提出日時 2023-01-20 21:36:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 738 ms / 2,000 ms
コード長 720 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 87,308 KB
実行使用メモリ 89,200 KB
最終ジャッジ日時 2023-09-05 13:47:37
合計ジャッジ時間 10,783 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,480 KB
testcase_01 AC 80 ms
71,612 KB
testcase_02 AC 609 ms
81,540 KB
testcase_03 AC 688 ms
84,576 KB
testcase_04 AC 618 ms
82,336 KB
testcase_05 AC 717 ms
84,172 KB
testcase_06 AC 736 ms
84,040 KB
testcase_07 AC 670 ms
81,992 KB
testcase_08 AC 738 ms
83,468 KB
testcase_09 AC 633 ms
80,368 KB
testcase_10 AC 715 ms
88,824 KB
testcase_11 AC 689 ms
89,108 KB
testcase_12 AC 666 ms
89,200 KB
testcase_13 AC 675 ms
88,832 KB
testcase_14 AC 674 ms
88,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

bit=[0 for _ in range(30)]

q=int(input())

S=set()
for _ in range(q):
    A=list(map(int,input().split()))
    if A[0]==1:
        x=A[1]
        if x in S:
            continue
        S.add(x)
        cnt=0
        while(x>0):
            bit[cnt]+=x%2
            x//=2
            cnt+=1

    if A[0]==2:
        x=A[1]
        if x not in S:
            continue
        S.remove(x)
        cnt=0
        while(x>0):
            bit[cnt]-=x%2
            x//=2
            cnt+=1
    if A[0]==3:
        L=len(S)
        if L==0:
            print(-1)
            continue
        cnt=0
        b_and=0
        for i in range(30):
            if bit[i]==L:
                b_and+=2**i
        print(b_and)
        
0