結果

問題 No.2195 AND Set
ユーザー rlangevinrlangevin
提出日時 2023-01-20 21:35:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 445 ms / 2,000 ms
コード長 762 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 87,592 KB
最終ジャッジ日時 2023-09-05 13:46:52
合計ジャッジ時間 6,854 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,372 KB
testcase_01 AC 73 ms
71,556 KB
testcase_02 AC 329 ms
80,836 KB
testcase_03 AC 376 ms
81,516 KB
testcase_04 AC 335 ms
80,644 KB
testcase_05 AC 357 ms
82,308 KB
testcase_06 AC 363 ms
82,004 KB
testcase_07 AC 315 ms
79,712 KB
testcase_08 AC 367 ms
81,876 KB
testcase_09 AC 293 ms
79,284 KB
testcase_10 AC 433 ms
86,756 KB
testcase_11 AC 443 ms
87,508 KB
testcase_12 AC 436 ms
87,592 KB
testcase_13 AC 443 ms
87,480 KB
testcase_14 AC 445 ms
87,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline

Q = int(readline())
S = set()
M = 35
D = [0] * M
cnt = 0
for _ in range(Q):
    query = list(map(int, readline().split()))
    if query[0] == 1:
        x = query[1]
        if x in S:
            continue
        S.add(x)
        cnt += 1
        for i in range(M):
            if (x >> i) & 1:
                D[i] += 1
    elif query[0] == 2:
        x = query[1]
        if x in S:
            S.discard(query[1])
            cnt -= 1
            for i in range(M):
                if (x >> i) & 1:
                    D[i] -= 1
    else:
        v = 0
        if cnt == 0:
            print(-1)
            continue
        for i in range(M):
            if D[i] == cnt:
                v += 1 << i
        print(v)
0