結果

問題 No.2195 AND Set
ユーザー ikomaikoma
提出日時 2023-01-20 22:08:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 461 ms / 2,000 ms
コード長 677 bytes
コンパイル時間 647 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 88,304 KB
最終ジャッジ日時 2023-09-05 14:25:44
合計ジャッジ時間 7,642 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,604 KB
testcase_01 AC 76 ms
71,496 KB
testcase_02 AC 347 ms
80,432 KB
testcase_03 AC 385 ms
82,692 KB
testcase_04 AC 343 ms
81,004 KB
testcase_05 AC 349 ms
81,908 KB
testcase_06 AC 381 ms
82,668 KB
testcase_07 AC 321 ms
79,936 KB
testcase_08 AC 358 ms
81,808 KB
testcase_09 AC 305 ms
79,748 KB
testcase_10 AC 453 ms
88,304 KB
testcase_11 AC 457 ms
88,184 KB
testcase_12 AC 443 ms
87,700 KB
testcase_13 AC 461 ms
87,612 KB
testcase_14 AC 447 ms
87,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

Q=int(input())
S=set()
ans=[0]*30

for _ in range(Q):
    q=list(map(int,input().split()))
    if q[0]==1:
        x=q[1]
        if x not in S:
            S.add(x)
            for i in range(30):
                if (x>>i)&1:
                    ans[i]+=1
    elif q[0]==2:
        x=q[1]
        if x in S:
            S.discard(x)
            for i in range(30):
                if (x>>i)&1:
                    ans[i]-=1
    else:
        if len(S)==0:
            print(-1)
        else:
            x=0
            for a in ans[::-1]:
                x<<=1
                if a==len(S):
                    x+=1
            print(x)
0