結果

問題 No.2195 AND Set
ユーザー ShirotsumeShirotsume
提出日時 2022-11-28 23:01:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 590 ms / 2,000 ms
コード長 879 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 132,608 KB
最終ジャッジ日時 2024-04-15 20:21:02
合計ジャッジ時間 8,942 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,096 KB
testcase_01 AC 39 ms
52,096 KB
testcase_02 AC 450 ms
120,320 KB
testcase_03 AC 476 ms
121,984 KB
testcase_04 AC 462 ms
120,320 KB
testcase_05 AC 470 ms
123,520 KB
testcase_06 AC 485 ms
123,520 KB
testcase_07 AC 468 ms
121,984 KB
testcase_08 AC 483 ms
123,776 KB
testcase_09 AC 455 ms
121,344 KB
testcase_10 AC 590 ms
132,224 KB
testcase_11 AC 581 ms
132,352 KB
testcase_12 AC 590 ms
132,608 KB
testcase_13 AC 581 ms
132,224 KB
testcase_14 AC 563 ms
132,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(q, qu):
    s = set()
    X = []
    bit = [0] * 30
    for v in qu:
        t = v[0]
        if t == 1:
            x = v[1]
            if x not in s:
                s.add(x)
                for i in range(30):
                    if 1 & (x >> i):
                        bit[i] += 1
        elif t == 2:
            x = v[1]
            if x in s:
                s.discard(x)
                for i in range(30):
                    if 1 & (x >> i):
                        bit[i] -= 1
        else:
            ans = 0
            if len(s) == 0:
                X.append(-1)
            else:
                for i in range(30):
                    if bit[i] == len(s):
                        ans += 2 ** i 
                X.append(ans)
    return X

q = int(input())

qu = [list(map(int,input().split())) for _ in range(q)]

for v in solve(q, qu):
    print(v)
0