結果
| 問題 |
No.2195 AND Set
|
| コンテスト | |
| ユーザー |
minato
|
| 提出日時 | 2023-03-09 13:40:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 677 ms / 2,000 ms |
| コード長 | 708 bytes |
| コンパイル時間 | 197 ms |
| コンパイル使用メモリ | 82,300 KB |
| 実行使用メモリ | 85,816 KB |
| 最終ジャッジ日時 | 2024-09-18 02:53:13 |
| 合計ジャッジ時間 | 9,371 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 |
ソースコード
freq = [0] * 30
dic = set()
Q = int(input())
cnt = 0
for _ in range(Q):
query = input().split()
if query[0] == "1":
x = int(query[1])
if x not in dic:
dic.add(x)
for i in range(30):
if x & (1 << i):
freq[i] += 1
elif query[0] == "2":
x = int(query[1])
if x in dic:
dic.remove(x)
for i in range(30):
if x & (1 << i):
freq[i] -= 1
else:
x = len(dic)
if x == 0:
print(-1)
continue
ans = 0
for i in range(30):
if freq[i] == x:
ans += 1 << i
print(ans)
minato