結果
問題 | No.2195 AND Set |
ユーザー | n_na |
提出日時 | 2023-01-21 03:52:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 975 ms / 2,000 ms |
コード長 | 815 bytes |
コンパイル時間 | 263 ms |
コンパイル使用メモリ | 86,920 KB |
実行使用メモリ | 91,532 KB |
最終ジャッジ日時 | 2023-09-05 19:41:15 |
合計ジャッジ時間 | 12,340 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 74 ms
71,340 KB |
testcase_01 | AC | 73 ms
71,112 KB |
testcase_02 | AC | 672 ms
82,824 KB |
testcase_03 | AC | 730 ms
83,452 KB |
testcase_04 | AC | 632 ms
83,212 KB |
testcase_05 | AC | 777 ms
82,988 KB |
testcase_06 | AC | 797 ms
84,004 KB |
testcase_07 | AC | 697 ms
82,448 KB |
testcase_08 | AC | 787 ms
82,956 KB |
testcase_09 | AC | 622 ms
80,484 KB |
testcase_10 | AC | 904 ms
91,356 KB |
testcase_11 | AC | 975 ms
91,532 KB |
testcase_12 | AC | 882 ms
89,824 KB |
testcase_13 | AC | 861 ms
91,008 KB |
testcase_14 | AC | 951 ms
90,720 KB |
ソースコード
Q = int(input()) se = set() res = 1<<30 cnt = [0]*31 for _ in range(Q): qu = list(map(int,input().split())) if qu[0] == 1: k = qu[1] if k not in se: se.add(k) res &= k b = format(k,"b") for i in range(len(b)): if b[~i] == "1": cnt[i] += 1 elif qu[0] == 2: k = qu[1] if k in se: se.remove(k) b = format(k,"b") for i in range(len(b)): if b[~i] == "1": cnt[i] -= 1 res = 0 for j in range(31): if cnt[j] == len(se): res += pow(2,j) else: if len(se) == 0: print(-1) else: print(res)