結果
| 問題 |
No.2195 AND Set
|
| コンテスト | |
| ユーザー |
SidewaysOwl
|
| 提出日時 | 2023-01-20 23:46:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 723 ms / 2,000 ms |
| コード長 | 799 bytes |
| コンパイル時間 | 191 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 104,972 KB |
| 最終ジャッジ日時 | 2024-06-23 11:44:30 |
| 合計ジャッジ時間 | 10,363 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 |
ソースコード
from collections import defaultdict
d = defaultdict(int)
q = int(input())
l = [0] *30
cnt = 0
for _ in range(q):
qr = list(input().split())
if qr[0] == "1":
x = int(qr[1])
if d[x] == 0:
d[x] = 1
cnt += 1
i = 0
while x:
if x & 1:l[i] += 1
x >>= 1
i += 1
elif qr[0] == "2":
x = int(qr[1])
if d[x] :
d[x] = 0
cnt -= 1
i = 0
while x:
if x & 1:l[i] -= 1
x >>= 1
i += 1
else:
if cnt == 0:print(-1)
else:
ans = 0
for i in range(30):
if l[i] == cnt:
ans += 2 ** i
print(ans)
SidewaysOwl