結果
問題 | No.2195 AND Set |
ユーザー |
|
提出日時 | 2023-01-27 13:53:18 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,252 bytes |
コンパイル時間 | 151 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 19,596 KB |
最終ジャッジ日時 | 2024-06-28 00:46:53 |
合計ジャッジ時間 | 30,144 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 TLE * 5 |
ソースコード
from collections import defaultdict def main(): S = set() S_bit_digit = defaultdict(int) 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 in S_bit_digit if S_bit_digit[digit_idx] == len(S))) case _: raise ValueError if __name__ == "__main__": main()