結果

問題 No.2672 Subset Xor Sum
ユーザー 👑 kakel-sankakel-san
提出日時 2024-03-15 21:44:31
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,377 bytes
コンパイル時間 14,600 ms
コンパイル使用メモリ 158,184 KB
実行使用メモリ 179,368 KB
最終ジャッジ日時 2024-03-15 21:44:59
合計ジャッジ時間 17,514 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
32,932 KB
testcase_01 AC 85 ms
32,932 KB
testcase_02 AC 83 ms
33,060 KB
testcase_03 AC 82 ms
33,060 KB
testcase_04 AC 82 ms
33,060 KB
testcase_05 AC 83 ms
33,060 KB
testcase_06 AC 84 ms
33,060 KB
testcase_07 AC 82 ms
33,060 KB
testcase_08 AC 82 ms
33,060 KB
testcase_09 AC 82 ms
33,060 KB
testcase_10 AC 82 ms
33,060 KB
testcase_11 AC 83 ms
33,060 KB
testcase_12 AC 83 ms
33,060 KB
testcase_13 AC 83 ms
33,060 KB
testcase_14 AC 84 ms
33,060 KB
testcase_15 AC 84 ms
33,060 KB
testcase_16 AC 83 ms
33,060 KB
testcase_17 AC 83 ms
33,060 KB
testcase_18 AC 82 ms
33,060 KB
testcase_19 AC 83 ms
33,060 KB
testcase_20 AC 83 ms
33,060 KB
testcase_21 AC 84 ms
33,060 KB
testcase_22 AC 83 ms
33,060 KB
testcase_23 AC 82 ms
33,060 KB
testcase_24 AC 83 ms
33,060 KB
testcase_25 AC 97 ms
32,804 KB
testcase_26 AC 85 ms
32,804 KB
testcase_27 AC 88 ms
33,060 KB
testcase_28 AC 93 ms
33,060 KB
testcase_29 AC 116 ms
33,060 KB
testcase_30 AC 198 ms
63,100 KB
testcase_31 AC 122 ms
46,556 KB
testcase_32 AC 117 ms
42,916 KB
testcase_33 AC 147 ms
54,184 KB
testcase_34 AC 171 ms
62,440 KB
testcase_35 AC 159 ms
58,088 KB
testcase_36 AC 198 ms
61,176 KB
testcase_37 AC 128 ms
46,244 KB
testcase_38 AC 188 ms
65,576 KB
testcase_39 AC 103 ms
39,076 KB
testcase_40 AC 122 ms
51,156 KB
testcase_41 AC 145 ms
58,824 KB
testcase_42 AC 136 ms
53,972 KB
testcase_43 AC 155 ms
63,816 KB
testcase_44 AC 132 ms
53,472 KB
testcase_45 AC 80 ms
33,060 KB
testcase_46 AC 240 ms
56,484 KB
testcase_47 AC 83 ms
33,060 KB
testcase_48 AC 82 ms
33,060 KB
testcase_49 AC 83 ms
33,060 KB
testcase_50 AC 242 ms
56,484 KB
testcase_51 AC 85 ms
33,188 KB
testcase_52 AC 85 ms
33,188 KB
testcase_53 AC 239 ms
56,612 KB
testcase_54 AC 242 ms
56,612 KB
testcase_55 AC 82 ms
33,060 KB
testcase_56 AC 198 ms
56,612 KB
testcase_57 AC 129 ms
52,388 KB
testcase_58 AC 81 ms
32,804 KB
testcase_59 AC 80 ms
32,932 KB
testcase_60 AC 81 ms
32,804 KB
testcase_61 AC 159 ms
56,612 KB
testcase_62 AC 172 ms
56,612 KB
testcase_63 AC 86 ms
33,188 KB
testcase_64 AC 133 ms
52,516 KB
testcase_65 WA -
testcase_66 AC 82 ms
179,368 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (110 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray();
    static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var a = NList;
        WriteLine(Xor(n, a) ? "Yes" : "No");
    }
    static bool Xor(int n, int[] a)
    {
        var all = a.Aggregate((x, ai) => x ^ ai);
        if (all != 0) return false;
        var set = new HashSet<int>(a);
        if (set.Count < n) return true;
        var dp1 = new bool[8192];
        dp1[a[0]] = true;
        var dp2 = new bool[8192];
        for (var i = 1; i < n; ++i)
        {
            var ndp1 = new bool[8192];
            var ndp2 = new bool[8192];
            for (var b = 0; b < dp1.Length; ++b)
            {
                ndp1[b ^ a[i]] |= dp1[b];
                ndp2[b] |= dp1[b];
                ndp2[b ^ a[i]] |= dp2[b];
                ndp2[b] |= dp2[b];
            }
            dp1 = ndp1;
            dp2 = ndp2;
        }
        return dp2[0];
    }
}
 
0