結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー magurogumamaguroguma
提出日時 2017-08-15 00:42:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 38 ms / 5,000 ms
コード長 608 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 9,992 KB
最終ジャッジ日時 2023-09-12 14:29:47
合計ジャッジ時間 1,646 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
8,580 KB
testcase_01 AC 23 ms
8,668 KB
testcase_02 AC 23 ms
8,596 KB
testcase_03 AC 22 ms
8,724 KB
testcase_04 AC 21 ms
8,656 KB
testcase_05 AC 26 ms
8,548 KB
testcase_06 AC 21 ms
8,628 KB
testcase_07 AC 37 ms
9,796 KB
testcase_08 AC 31 ms
9,788 KB
testcase_09 AC 29 ms
9,580 KB
testcase_10 AC 30 ms
9,608 KB
testcase_11 AC 31 ms
9,892 KB
testcase_12 AC 32 ms
8,508 KB
testcase_13 AC 21 ms
8,648 KB
testcase_14 AC 24 ms
9,696 KB
testcase_15 AC 30 ms
9,992 KB
testcase_16 AC 22 ms
8,628 KB
testcase_17 AC 28 ms
8,880 KB
testcase_18 AC 38 ms
9,956 KB
testcase_19 AC 28 ms
8,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

import sys

def solution(i, m, dp, A, N):
    if not dp[m]:
        if i<N-1:
            solution(i+1, m, dp, A, N)
        dp[m] = True
    if not dp[m^A[i]]:
        if i<N-1:
            solution(i+1, m^A[i], dp, A, N)
        dp[m^A[i]] = True

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    sys.setrecursionlimit(6000)

    # dp = [False] * 40000
    dp = []
    for i in range(40000):
        dp.append(False)

    solution(0, 0, dp, A, N)
    pattern = 0
    for b in dp:
        if b:
            pattern += 1
    print(pattern)
0