結果

問題 No.2195 AND Set
ユーザー mkawa2mkawa2
提出日時 2023-01-20 21:31:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 435 ms / 2,000 ms
コード長 1,285 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 87,348 KB
実行使用メモリ 88,404 KB
最終ジャッジ日時 2023-09-05 13:41:26
合計ジャッジ時間 7,253 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,276 KB
testcase_01 AC 72 ms
71,312 KB
testcase_02 AC 400 ms
80,816 KB
testcase_03 AC 429 ms
82,084 KB
testcase_04 AC 377 ms
79,996 KB
testcase_05 AC 387 ms
82,452 KB
testcase_06 AC 402 ms
82,668 KB
testcase_07 AC 361 ms
79,864 KB
testcase_08 AC 392 ms
82,504 KB
testcase_09 AC 325 ms
79,108 KB
testcase_10 AC 435 ms
88,112 KB
testcase_11 AC 431 ms
88,092 KB
testcase_12 AC 428 ms
88,404 KB
testcase_13 AC 431 ms
87,928 KB
testcase_14 AC 432 ms
88,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(1000005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

q = II()
s = set()
cnt = [0]*30
a = (1 << 30)-1

for _ in range(q):
    t, *xx = LI()
    if t == 1:
        x = xx[0]
        if x not in s:
            for i in range(30): cnt[i] += x >> i & 1
            s.add(x)
    if t == 2:
        x = xx[0]
        if x in s:
            for i in range(30): cnt[i] -= x >> i & 1
            s.discard(x)
    if t == 3:
        if s:
            ans = 0
            for i in range(30):
                if cnt[i] == len(s):
                    ans |= 1 << i
            print(ans)
        else:
            print(-1)
0