結果

問題 No.2195 AND Set
ユーザー pluto77pluto77
提出日時 2023-01-23 16:21:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 759 ms / 2,000 ms
コード長 426 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 91,392 KB
最終ジャッジ日時 2023-09-07 18:26:33
合計ジャッジ時間 13,283 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,572 KB
testcase_01 AC 70 ms
70,956 KB
testcase_02 AC 626 ms
82,764 KB
testcase_03 AC 680 ms
84,500 KB
testcase_04 AC 622 ms
83,808 KB
testcase_05 AC 759 ms
84,672 KB
testcase_06 AC 739 ms
85,608 KB
testcase_07 AC 704 ms
82,428 KB
testcase_08 AC 742 ms
84,840 KB
testcase_09 AC 620 ms
79,680 KB
testcase_10 AC 728 ms
89,284 KB
testcase_11 AC 756 ms
89,960 KB
testcase_12 AC 747 ms
90,284 KB
testcase_13 AC 753 ms
90,448 KB
testcase_14 AC 735 ms
91,392 KB
権限があれば一括ダウンロードができます

ソースコード

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