結果

問題 No.2195 AND Set
コンテスト
ユーザー titia
提出日時 2023-01-21 00:04:55
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 758 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 692 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 23,460 KB
最終ジャッジ日時 2026-03-08 06:16:48
合計ジャッジ時間 20,019 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11 WA * 1 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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:
        ANS=-1

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

        print(ANS)
            
0