結果

問題 No.2672 Subset Xor Sum
ユーザー 👑 eoeoeoeo
提出日時 2024-02-11 23:52:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 616 ms / 2,000 ms
コード長 837 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 202,644 KB
最終ジャッジ日時 2024-03-16 17:37:49
合計ジャッジ時間 7,548 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
59,380 KB
testcase_01 AC 39 ms
59,380 KB
testcase_02 AC 47 ms
61,588 KB
testcase_03 AC 47 ms
61,588 KB
testcase_04 AC 47 ms
61,588 KB
testcase_05 AC 46 ms
63,680 KB
testcase_06 AC 47 ms
63,680 KB
testcase_07 AC 46 ms
61,588 KB
testcase_08 AC 42 ms
61,588 KB
testcase_09 AC 44 ms
61,588 KB
testcase_10 AC 44 ms
61,588 KB
testcase_11 AC 47 ms
61,588 KB
testcase_12 AC 44 ms
61,588 KB
testcase_13 AC 43 ms
61,588 KB
testcase_14 AC 45 ms
61,588 KB
testcase_15 AC 43 ms
61,588 KB
testcase_16 AC 44 ms
61,588 KB
testcase_17 AC 43 ms
61,588 KB
testcase_18 AC 43 ms
61,588 KB
testcase_19 AC 43 ms
61,588 KB
testcase_20 AC 44 ms
61,588 KB
testcase_21 AC 44 ms
61,588 KB
testcase_22 AC 44 ms
61,588 KB
testcase_23 AC 45 ms
61,588 KB
testcase_24 AC 47 ms
61,588 KB
testcase_25 AC 43 ms
61,588 KB
testcase_26 AC 79 ms
71,864 KB
testcase_27 AC 78 ms
71,864 KB
testcase_28 AC 48 ms
63,696 KB
testcase_29 AC 47 ms
63,696 KB
testcase_30 AC 48 ms
61,588 KB
testcase_31 AC 126 ms
131,544 KB
testcase_32 AC 69 ms
96,100 KB
testcase_33 AC 66 ms
90,616 KB
testcase_34 AC 105 ms
111,148 KB
testcase_35 AC 124 ms
131,552 KB
testcase_36 AC 113 ms
115,856 KB
testcase_37 AC 122 ms
124,584 KB
testcase_38 AC 76 ms
101,920 KB
testcase_39 AC 131 ms
141,676 KB
testcase_40 AC 51 ms
76,024 KB
testcase_41 AC 87 ms
116,296 KB
testcase_42 AC 120 ms
124,588 KB
testcase_43 AC 107 ms
110,516 KB
testcase_44 AC 130 ms
141,536 KB
testcase_45 AC 104 ms
110,844 KB
testcase_46 AC 39 ms
59,712 KB
testcase_47 AC 55 ms
59,840 KB
testcase_48 AC 40 ms
59,712 KB
testcase_49 AC 39 ms
59,712 KB
testcase_50 AC 40 ms
59,712 KB
testcase_51 AC 39 ms
59,840 KB
testcase_52 AC 38 ms
59,840 KB
testcase_53 AC 38 ms
59,840 KB
testcase_54 AC 40 ms
59,840 KB
testcase_55 AC 38 ms
59,840 KB
testcase_56 AC 40 ms
59,712 KB
testcase_57 AC 40 ms
59,840 KB
testcase_58 AC 39 ms
59,840 KB
testcase_59 AC 34 ms
53,460 KB
testcase_60 AC 38 ms
59,712 KB
testcase_61 AC 38 ms
59,712 KB
testcase_62 AC 616 ms
202,644 KB
testcase_63 AC 39 ms
59,840 KB
testcase_64 AC 39 ms
59,840 KB
testcase_65 AC 39 ms
59,840 KB
testcase_66 AC 38 ms
59,380 KB
testcase_67 AC 34 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/pypy3

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