結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー しらっ亭しらっ亭
提出日時 2015-07-22 00:58:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,038 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 21,396 KB
最終ジャッジ日時 2023-09-17 17:20:21
合計ジャッジ時間 13,737 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,788 KB
testcase_01 AC 16 ms
7,868 KB
testcase_02 AC 17 ms
7,964 KB
testcase_03 AC 17 ms
7,948 KB
testcase_04 AC 17 ms
7,752 KB
testcase_05 AC 17 ms
7,888 KB
testcase_06 AC 16 ms
7,800 KB
testcase_07 AC 16 ms
7,888 KB
testcase_08 AC 499 ms
17,100 KB
testcase_09 AC 114 ms
10,000 KB
testcase_10 AC 379 ms
14,976 KB
testcase_11 AC 273 ms
13,380 KB
testcase_12 AC 581 ms
18,476 KB
testcase_13 AC 626 ms
19,404 KB
testcase_14 AC 367 ms
14,364 KB
testcase_15 AC 674 ms
21,396 KB
testcase_16 AC 560 ms
19,220 KB
testcase_17 AC 614 ms
19,108 KB
testcase_18 AC 16 ms
7,796 KB
testcase_19 AC 16 ms
7,752 KB
testcase_20 AC 47 ms
10,084 KB
testcase_21 AC 698 ms
20,892 KB
testcase_22 AC 688 ms
20,836 KB
testcase_23 AC 16 ms
7,852 KB
testcase_24 AC 17 ms
7,820 KB
testcase_25 AC 16 ms
7,896 KB
testcase_26 AC 16 ms
7,824 KB
testcase_27 AC 17 ms
7,888 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 672 ms
21,380 KB
testcase_34 AC 673 ms
20,152 KB
testcase_35 AC 691 ms
20,696 KB
testcase_36 AC 688 ms
20,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

    for i in range(N):
        a = A[i]
        if a:
            h = 1 << highest(a)
            for j in range(i + 1, N):
                if A[j] & h:
                    A[j] ^= h

    print(1 << sum(1 for a in A if a))


def main():
    solve()


def bitcount(x):
    """
    立っているbitの数
    """
    x = (x & 0x5555555555555555) + (x >> 1 & 0x5555555555555555)
    x = (x & 0x3333333333333333) + (x >> 2 & 0x3333333333333333)
    x = (x & 0x0f0f0f0f0f0f0f0f) + (x >> 4 & 0x0f0f0f0f0f0f0f0f)
    x = (x & 0x00ff00ff00ff00ff) + (x >> 8 & 0x00ff00ff00ff00ff)
    x = (x & 0x0000ffff0000ffff) + (x >> 16 & 0x0000ffff0000ffff)
    return (x & 0x00000000ffffffff) + (x >> 32 & 0x00000000ffffffff)


def highest(x):
    """
    一番左の立っているbitの位置
    """
    x |= (x >> 1)
    x |= (x >> 2)
    x |= (x >> 4)
    x |= (x >> 8)
    x |= (x >> 16)
    x |= (x >> 32)
    return bitcount(x) - 1


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