結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー しらっ亭しらっ亭
提出日時 2015-07-22 01:05:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 688 ms / 5,000 ms
コード長 1,038 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 21,380 KB
最終ジャッジ日時 2023-09-17 17:19:11
合計ジャッジ時間 13,198 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,944 KB
testcase_01 AC 16 ms
7,968 KB
testcase_02 AC 16 ms
7,776 KB
testcase_03 AC 16 ms
7,884 KB
testcase_04 AC 16 ms
7,944 KB
testcase_05 AC 16 ms
7,840 KB
testcase_06 AC 16 ms
7,824 KB
testcase_07 AC 16 ms
7,808 KB
testcase_08 AC 487 ms
16,924 KB
testcase_09 AC 114 ms
10,076 KB
testcase_10 AC 376 ms
15,012 KB
testcase_11 AC 270 ms
13,408 KB
testcase_12 AC 578 ms
18,428 KB
testcase_13 AC 607 ms
19,328 KB
testcase_14 AC 358 ms
14,384 KB
testcase_15 AC 653 ms
21,348 KB
testcase_16 AC 549 ms
19,092 KB
testcase_17 AC 596 ms
19,248 KB
testcase_18 AC 16 ms
7,944 KB
testcase_19 AC 16 ms
7,804 KB
testcase_20 AC 45 ms
10,116 KB
testcase_21 AC 688 ms
20,776 KB
testcase_22 AC 687 ms
20,656 KB
testcase_23 AC 15 ms
7,724 KB
testcase_24 AC 15 ms
7,836 KB
testcase_25 AC 16 ms
7,852 KB
testcase_26 AC 15 ms
7,828 KB
testcase_27 AC 16 ms
7,820 KB
testcase_28 AC 416 ms
16,532 KB
testcase_29 AC 576 ms
19,132 KB
testcase_30 AC 495 ms
18,592 KB
testcase_31 AC 417 ms
16,572 KB
testcase_32 AC 529 ms
19,264 KB
testcase_33 AC 674 ms
21,380 KB
testcase_34 AC 659 ms
20,180 KB
testcase_35 AC 677 ms
20,788 KB
testcase_36 AC 675 ms
20,648 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] ^= a

    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