結果

問題 No.2195 AND Set
ユーザー qibqib
提出日時 2023-04-17 00:53:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 724 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 88,964 KB
最終ジャッジ日時 2024-04-20 10:09:58
合計ジャッジ時間 11,871 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,608 KB
testcase_01 AC 43 ms
51,968 KB
testcase_02 AC 598 ms
79,892 KB
testcase_03 AC 668 ms
82,168 KB
testcase_04 AC 604 ms
80,596 KB
testcase_05 AC 703 ms
81,456 KB
testcase_06 AC 724 ms
82,064 KB
testcase_07 AC 665 ms
78,984 KB
testcase_08 AC 707 ms
82,056 KB
testcase_09 AC 618 ms
78,080 KB
testcase_10 AC 703 ms
88,124 KB
testcase_11 AC 698 ms
87,996 KB
testcase_12 AC 671 ms
88,696 KB
testcase_13 AC 673 ms
88,340 KB
testcase_14 AC 686 ms
88,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

q = int(input())

s = set()
bit = [[0 for _ in range(2)] for _ in range(30)]
for _ in range(q):
  t, *args = list(map(int, input().split()))
  if t == 1:
    xi = args[0]
    if not xi in s:
      for i in range(30):
        bit[i][(xi >> i) & 1] += 1
      s.add(xi)
  elif t == 2:
    xi = args[0]
    if xi in s:
      for i in range(30):
        bit[i][(xi >> i) & 1] -= 1
      s.discard(xi)
  elif t == 3:
    if len(s) == 0:
      print("-1")
    else:
      ans = 0
      for i in range(30):
        if bit[i][1] > 0 and bit[i][0] == 0:
          ans |= (1 << i)
      print(ans)
0