結果
問題 |
No.2195 AND Set
|
ユーザー |
![]() |
提出日時 | 2023-01-20 21:37:46 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 815 ms / 2,000 ms |
コード長 | 904 bytes |
コンパイル時間 | 194 ms |
コンパイル使用メモリ | 82,316 KB |
実行使用メモリ | 87,544 KB |
最終ジャッジ日時 | 2024-06-23 09:31:02 |
合計ジャッジ時間 | 10,733 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 |
ソースコード
def resolve(): q = int(input()) s = set() cnt = [0] * 30 for _ in range(q): query = tuple(map(int, input().split())) if query[0] == 1: x = query[1] if x not in s: s.add(x) i = 0 while x: if x & 1: cnt[i] += 1 x >>= 1 i += 1 elif query[0] == 2: x = query[1] if x in s: s.remove(x) i = 0 while x: if x & 1: cnt[i] -= 1 x >>= 1 i += 1 else: if s: print(sum(1 << i for i, x in enumerate(cnt) if x == len(s))) else: print(-1) # print(s, cnt) if __name__ == "__main__": resolve()