結果

問題 No.2195 AND Set
ユーザー ygd.ygd.
提出日時 2023-01-20 21:42:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,482 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 10,792 KB
実行使用メモリ 17,380 KB
最終ジャッジ日時 2023-09-05 13:57:29
合計ジャッジ時間 26,524 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
8,732 KB
testcase_01 AC 22 ms
8,832 KB
testcase_02 AC 1,280 ms
9,824 KB
testcase_03 AC 1,429 ms
11,832 KB
testcase_04 AC 1,263 ms
9,712 KB
testcase_05 AC 1,690 ms
11,836 KB
testcase_06 AC 1,680 ms
12,000 KB
testcase_07 AC 1,434 ms
9,624 KB
testcase_08 AC 1,690 ms
11,960 KB
testcase_09 AC 1,393 ms
9,000 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline #文字列はダメ
#sys.setrecursionlimit(1000000)
#import math
#import bisect
#import itertools
#import random
#from heapq import heapify, heappop, heappush
from collections import defaultdict
from collections import deque
import copy #DeepCopy: hoge = [_[:] for _ in hogehoge]
#from functools import lru_cache
#@lru_cache(maxsize=None)
MOD = pow(10,9) + 7
#MOD = 998244353
dx = [1,0,-1,0]
dy = [0,1,0,-1]
#dx8 = [1,1,0,-1,-1,-1,0,1]
#dy8 = [0,1,1,1,0,-1,-1,-1]

def main():
    Q = int(input())
    MX = 32
    S = set([])
    num = [0]*MX
    ans = 0
    for _ in range(Q):
        query = str(input())
        if len(query) == 1:
            if len(S) == 0:
                print(-1)
            else:
                print(ans)
        else:
            x = int(query[2:])
            if int(query[0]) == 1:
                if x in S:
                    continue
                S.add(x)
                for i in range(MX):
                    if (x>>i)&1 == 1:
                        num[i] += 1
            else:
                if x not in S:
                    continue
                S.remove(x)
                for i in range(MX):
                    if (x>>i)&1 == 1:
                        num[i] -= 1
            # print(S,num)
            ans = 0
            for i in range(MX):
                if num[i] == len(S):
                    ans += 1<<i


if __name__ == '__main__':
    main()
0