結果

問題 No.2195 AND Set
ユーザー strangerxxxstrangerxxx
提出日時 2023-01-20 21:37:46
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 851 ms / 2,000 ms
コード長 904 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 90,800 KB
最終ジャッジ日時 2023-09-05 13:49:04
合計ジャッジ時間 11,461 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,580 KB
testcase_01 AC 74 ms
71,156 KB
testcase_02 AC 546 ms
80,880 KB
testcase_03 AC 591 ms
82,428 KB
testcase_04 AC 571 ms
80,340 KB
testcase_05 AC 716 ms
83,476 KB
testcase_06 AC 763 ms
83,916 KB
testcase_07 AC 689 ms
80,568 KB
testcase_08 AC 729 ms
83,124 KB
testcase_09 AC 652 ms
80,296 KB
testcase_10 AC 851 ms
90,800 KB
testcase_11 AC 784 ms
89,400 KB
testcase_12 AC 838 ms
90,212 KB
testcase_13 AC 742 ms
89,084 KB
testcase_14 AC 735 ms
88,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def resolve():
    q = int(input())
    s = set()
    cnt = [0] * 30
    for _ in range(q):
        query = tuple(map(int, input().split()))
        if query[0] == 1:
            x = query[1]
            if x not in s:
                s.add(x)
                i = 0
                while x:
                    if x & 1:
                        cnt[i] += 1
                    x >>= 1
                    i += 1
        elif query[0] == 2:
            x = query[1]
            if x in s:
                s.remove(x)
                i = 0
                while x:
                    if x & 1:
                        cnt[i] -= 1
                    x >>= 1
                    i += 1
        else:
            if s:
                print(sum(1 << i for i, x in enumerate(cnt) if x == len(s)))
            else:
                print(-1)
        # print(s, cnt)


if __name__ == "__main__":
    resolve()
0