結果

問題 No.2195 AND Set
ユーザー titiatitia
提出日時 2023-01-21 00:08:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 444 ms / 2,000 ms
コード長 766 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 88,144 KB
最終ジャッジ日時 2023-09-05 16:36:29
合計ジャッジ時間 7,297 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,404 KB
testcase_01 AC 70 ms
71,488 KB
testcase_02 AC 325 ms
80,228 KB
testcase_03 AC 372 ms
81,264 KB
testcase_04 AC 320 ms
80,896 KB
testcase_05 AC 360 ms
81,852 KB
testcase_06 AC 362 ms
81,492 KB
testcase_07 AC 300 ms
79,336 KB
testcase_08 AC 380 ms
81,700 KB
testcase_09 AC 294 ms
79,596 KB
testcase_10 AC 440 ms
88,092 KB
testcase_11 AC 443 ms
88,144 KB
testcase_12 AC 440 ms
87,516 KB
testcase_13 AC 443 ms
87,120 KB
testcase_14 AC 444 ms
87,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

Q=int(input())
S=set()
A=[0]*32
ko=0

for tests in range(Q):
    X=list(map(int,input().split()))

    if X[0]==1:
        x=X[1]

        if x in S:
            pass
        else:
            S.add(x)
            ko+=1

            for i in range(32):
                if x & (1<<i) != 0:
                    A[i]+=1

    elif X[0]==2:
        x=X[1]

        if x in S:
            S.remove(x)
            ko-=1

            for i in range(32):
                if x & (1<<i) != 0:
                    A[i]-=1

    else:
        if ko==0:
            ANS=-1
        else:
            ANS=0
            for i in range(32):
                if A[i]>0 and A[i]==ko:
                    ANS|=(1<<i)

        print(ANS)
            
0