結果
| 問題 |
No.2195 AND Set
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-27 15:04:41 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,271 bytes |
| コンパイル時間 | 121 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 19,540 KB |
| 最終ジャッジ日時 | 2024-06-28 01:35:16 |
| 合計ジャッジ時間 | 27,754 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 TLE * 5 |
ソースコード
from collections import defaultdict
def main():
S = set()
S_bit_digit = [0 for _ in range(30)]
for _ in range(int(input())):
query = input().split()
if len(query) == 1:
query_type = 3
else:
query_type, x = map(int, query)
match query_type:
case 1:
if x in S:
continue
S.add(x)
digit_idx = 0
while x > 0:
if x & 1:
S_bit_digit[digit_idx] += 1
x >>= 1
digit_idx += 1
case 2:
if x not in S:
continue
S.remove(x)
digit_idx = 0
while x > 0:
if x & 1:
S_bit_digit[digit_idx] -= 1
x >>= 1
digit_idx += 1
case 3:
if not S:
print(-1)
else:
print(
sum(2**digit_idx for digit_idx, digit_value in enumerate(S_bit_digit) if digit_value == len(S)))
case _:
raise ValueError
if __name__ == "__main__":
main()