結果

問題 No.2195 AND Set
ユーザー flygonflygon
提出日時 2023-01-20 21:34:45
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 762 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 90,628 KB
最終ジャッジ日時 2023-09-05 13:45:25
合計ジャッジ時間 11,424 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,400 KB
testcase_01 AC 77 ms
71,516 KB
testcase_02 AC 608 ms
81,204 KB
testcase_03 AC 670 ms
85,628 KB
testcase_04 AC 638 ms
82,976 KB
testcase_05 AC 741 ms
84,040 KB
testcase_06 AC 762 ms
84,760 KB
testcase_07 AC 669 ms
80,976 KB
testcase_08 AC 722 ms
82,412 KB
testcase_09 AC 634 ms
79,816 KB
testcase_10 AC 753 ms
89,956 KB
testcase_11 AC 760 ms
89,604 KB
testcase_12 AC 742 ms
90,628 KB
testcase_13 AC 755 ms
89,472 KB
testcase_14 AC 758 ms
90,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

q = int(input())

now = [0]*(35)
s = set()
cnt = 0

for i in range(q):
  l = list(map(int,input().split()))
  t = l[0]
  if t == 1:
    x = l[1]
    if x in s:
      continue
    else:
      s.add(x)
      for j in range(35):
        if (x>>j) & 1:
          now[j] += 1
      cnt += 1
  elif t == 2:
    x = l[1]
    if x in s:
      s.discard(x)
      for j in range(35):
        if (x>>j) & 1:
          now[j] -= 1
      cnt -= 1
  else:
    if cnt == 0:
      print(-1)
      continue
    ans = 0
    for j in range(35):
      if now[j] == cnt:
        ans += 1 << j
    print(ans)

0