結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー rpy3cpprpy3cpp
提出日時 2015-04-17 14:52:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 588 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 8,848 KB
最終ジャッジ日時 2023-09-11 11:03:56
合計ジャッジ時間 1,412 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,832 KB
testcase_01 AC 16 ms
7,976 KB
testcase_02 AC 16 ms
7,800 KB
testcase_03 AC 15 ms
7,936 KB
testcase_04 AC 16 ms
7,880 KB
testcase_05 AC 16 ms
7,804 KB
testcase_06 AC 16 ms
7,784 KB
testcase_07 AC 24 ms
8,748 KB
testcase_08 AC 24 ms
8,848 KB
testcase_09 AC 22 ms
8,536 KB
testcase_10 AC 23 ms
8,544 KB
testcase_11 AC 25 ms
8,752 KB
testcase_12 AC 15 ms
7,856 KB
testcase_13 AC 16 ms
7,880 KB
testcase_14 AC 16 ms
8,288 KB
testcase_15 AC 25 ms
8,840 KB
testcase_16 AC 16 ms
7,784 KB
testcase_17 AC 18 ms
8,500 KB
testcase_18 AC 24 ms
8,644 KB
testcase_19 AC 17 ms
7,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def read_data():
    N = int(input())
    A = list(map(int, input().split()))
    return N, A

def solve(N, A):
    A = list(set(A))
    digits = len(bin(max(A))) - 2
    index = 1 << digits
    for rank in range(digits + 1):
        A.sort(reverse=True)
        if rank >= len(A):
            break
        Ar = A[rank]
        if Ar == 0:
            break
        while index and not Ar & index:
            index >>= 1
        i = rank + 1
        while i < len(A) and A[i] & index:
            A[i] ^= Ar
            i += 1
    return 1 << rank

N, A = read_data()
print(solve(N, A))
0