結果

問題 No.2672 Subset Xor Sum
ユーザー 👑 eoeoeoeo
提出日時 2024-02-13 21:04:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 819 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 156,948 KB
最終ジャッジ日時 2024-03-13 21:53:20
合計ジャッジ時間 9,634 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
17,300 KB
testcase_01 AC 40 ms
10,368 KB
testcase_02 AC 51 ms
10,880 KB
testcase_03 AC 53 ms
10,880 KB
testcase_04 AC 55 ms
11,008 KB
testcase_05 AC 53 ms
11,008 KB
testcase_06 AC 51 ms
11,008 KB
testcase_07 AC 51 ms
11,008 KB
testcase_08 AC 51 ms
11,008 KB
testcase_09 AC 53 ms
11,008 KB
testcase_10 AC 54 ms
11,008 KB
testcase_11 AC 51 ms
11,008 KB
testcase_12 AC 52 ms
11,008 KB
testcase_13 AC 52 ms
11,008 KB
testcase_14 AC 52 ms
11,008 KB
testcase_15 AC 52 ms
11,008 KB
testcase_16 AC 51 ms
11,008 KB
testcase_17 AC 51 ms
11,008 KB
testcase_18 AC 52 ms
11,008 KB
testcase_19 AC 51 ms
11,008 KB
testcase_20 AC 52 ms
11,008 KB
testcase_21 AC 53 ms
11,008 KB
testcase_22 AC 53 ms
11,008 KB
testcase_23 AC 50 ms
10,880 KB
testcase_24 AC 49 ms
10,880 KB
testcase_25 AC 315 ms
19,968 KB
testcase_26 AC 319 ms
19,968 KB
testcase_27 AC 56 ms
11,136 KB
testcase_28 AC 56 ms
11,136 KB
testcase_29 AC 51 ms
11,008 KB
testcase_30 AC 184 ms
61,464 KB
testcase_31 AC 92 ms
29,960 KB
testcase_32 AC 83 ms
26,760 KB
testcase_33 AC 141 ms
45,780 KB
testcase_34 AC 178 ms
59,564 KB
testcase_35 AC 154 ms
50,796 KB
testcase_36 AC 174 ms
56,808 KB
testcase_37 AC 103 ms
33,424 KB
testcase_38 AC 197 ms
66,028 KB
testcase_39 AC 58 ms
19,144 KB
testcase_40 AC 124 ms
42,464 KB
testcase_41 AC 171 ms
56,876 KB
testcase_42 AC 143 ms
47,460 KB
testcase_43 AC 198 ms
67,120 KB
testcase_44 AC 137 ms
47,128 KB
testcase_45 AC 31 ms
10,752 KB
testcase_46 AC 32 ms
10,752 KB
testcase_47 AC 32 ms
10,752 KB
testcase_48 AC 32 ms
10,752 KB
testcase_49 AC 31 ms
10,752 KB
testcase_50 AC 31 ms
10,752 KB
testcase_51 AC 31 ms
10,752 KB
testcase_52 AC 31 ms
10,752 KB
testcase_53 AC 34 ms
10,752 KB
testcase_54 AC 30 ms
10,752 KB
testcase_55 AC 31 ms
10,752 KB
testcase_56 AC 30 ms
10,496 KB
testcase_57 AC 30 ms
10,240 KB
testcase_58 AC 30 ms
10,240 KB
testcase_59 AC 30 ms
10,496 KB
testcase_60 AC 30 ms
10,368 KB
testcase_61 TLE -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def main():
    n = int(input())
    a = list(map(int, input().split()))

    xor_s = 0
    for i in range(n):
        xor_s ^= a[i]

    if xor_s != 0:
        print("No")
        sys.exit()

    if n > 5001:
        print("Yes")
        sys.exit()

    if min(a) == 0:
        print("Yes")
        sys.exit()

    MAX_XOR = 2**13
    INF = 10**9

    dp = [[INF for j in range(MAX_XOR)] for i in range(n)]

    dp[0][a[0]] = 1

    # 配るDP
    for i in range(1, n):
        for j in range(MAX_XOR):
            if (dp[i][j] > dp[i - 1][j]):
                dp[i][j] = dp[i - 1][j]
            if (dp[i][j] > dp[i - 1][j ^ a[i]] + 1):
                dp[i][j] = dp[i - 1][j ^ a[i]] + 1

    if (dp[n - 1][0] < n):
        print("Yes")
    else:
        print("No")

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