結果

問題 No.2195 AND Set
ユーザー flygon
提出日時 2023-01-20 21:34:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 710 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 87,528 KB
最終ジャッジ日時 2024-06-23 09:27:47
合計ジャッジ時間 10,271 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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