結果

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

ソースコード

diff #

Q=int(input())
s=set()
res=[0]*30

for i in range(Q):
 q=list(map(int,input().split()))
 if q[0]==1:
  if q[1] not in s:
   s.add(q[1])
   for j in range(30):
    if (q[1]>>j)&1:
     res[j]+=1
 elif q[0]==2:
  if q[1] in s:
   s.discard(q[1])
   for j in range(30):
    if (q[1]>>j)&1:
     res[j]-=1
 else:
  if len(s)==0:
   print(-1)
  else:
   x=0
   for a in res[::-1]:
    x<<=1
    if a==len(s):
     x+=1
   print(x)
0