結果

問題 No.2195 AND Set
ユーザー katonyonkokatonyonko
提出日時 2023-01-20 21:36:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,836 ms / 2,000 ms
コード長 598 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 86,832 KB
実行使用メモリ 227,708 KB
最終ジャッジ日時 2023-09-05 13:48:27
合計ジャッジ時間 17,677 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,608 KB
testcase_01 AC 75 ms
71,420 KB
testcase_02 AC 862 ms
85,548 KB
testcase_03 AC 1,140 ms
100,496 KB
testcase_04 AC 850 ms
86,208 KB
testcase_05 AC 913 ms
102,468 KB
testcase_06 AC 1,008 ms
101,896 KB
testcase_07 AC 684 ms
83,240 KB
testcase_08 AC 965 ms
101,116 KB
testcase_09 AC 531 ms
81,900 KB
testcase_10 AC 1,836 ms
225,740 KB
testcase_11 AC 1,773 ms
227,492 KB
testcase_12 AC 1,775 ms
225,492 KB
testcase_13 AC 1,760 ms
227,708 KB
testcase_14 AC 1,752 ms
225,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input():
  return sys.stdin.readline()[:-1]
Q=int(input())
ans=[set() for _ in range(30)]
S=set()
for _ in range(Q):
  query=list(map(int,input().split()))
  if query[0]==1:
    if query[1] not in S: S.add(query[1])
    for i in range(30):
      if query[1] not in ans[i] and (query[1]>>i)&1==1: ans[i].add(query[1])
  elif query[0]==2:
    if query[1] in S: S.remove(query[1])
    for i in range(30):
      if query[1] in ans[i] and (query[1]>>i)&1==1: ans[i].remove(query[1])
  else:
    if len(S)>0: print(sum([1<<i for i in range(30) if len(ans[i])==len(S)]))
    else: print(-1)
0