結果

問題 No.2672 Subset Xor Sum
ユーザー 👑 kakel-sankakel-san
提出日時 2024-03-15 21:50:18
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 1,425 bytes
コンパイル時間 14,128 ms
コンパイル使用メモリ 158,512 KB
実行使用メモリ 179,560 KB
最終ジャッジ日時 2024-03-16 17:41:19
合計ジャッジ時間 22,663 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
32,932 KB
testcase_01 AC 80 ms
32,932 KB
testcase_02 AC 80 ms
33,060 KB
testcase_03 AC 80 ms
33,060 KB
testcase_04 AC 80 ms
33,060 KB
testcase_05 AC 81 ms
33,060 KB
testcase_06 AC 80 ms
33,060 KB
testcase_07 AC 80 ms
33,060 KB
testcase_08 AC 82 ms
33,060 KB
testcase_09 AC 80 ms
33,060 KB
testcase_10 AC 81 ms
33,060 KB
testcase_11 AC 81 ms
33,060 KB
testcase_12 AC 80 ms
33,060 KB
testcase_13 AC 80 ms
33,060 KB
testcase_14 AC 81 ms
33,060 KB
testcase_15 AC 79 ms
33,060 KB
testcase_16 AC 80 ms
33,060 KB
testcase_17 AC 79 ms
33,060 KB
testcase_18 AC 80 ms
33,060 KB
testcase_19 AC 80 ms
33,060 KB
testcase_20 AC 80 ms
33,060 KB
testcase_21 AC 80 ms
33,060 KB
testcase_22 AC 79 ms
33,060 KB
testcase_23 AC 81 ms
33,060 KB
testcase_24 AC 82 ms
33,060 KB
testcase_25 AC 81 ms
33,060 KB
testcase_26 AC 83 ms
32,932 KB
testcase_27 AC 80 ms
32,932 KB
testcase_28 AC 80 ms
33,060 KB
testcase_29 AC 80 ms
33,060 KB
testcase_30 AC 81 ms
33,060 KB
testcase_31 AC 172 ms
63,100 KB
testcase_32 AC 120 ms
46,556 KB
testcase_33 AC 114 ms
42,916 KB
testcase_34 AC 143 ms
54,184 KB
testcase_35 AC 168 ms
62,440 KB
testcase_36 AC 153 ms
58,088 KB
testcase_37 AC 166 ms
61,176 KB
testcase_38 AC 125 ms
46,244 KB
testcase_39 AC 179 ms
65,576 KB
testcase_40 AC 99 ms
39,076 KB
testcase_41 AC 122 ms
51,156 KB
testcase_42 AC 141 ms
58,824 KB
testcase_43 AC 135 ms
53,972 KB
testcase_44 AC 154 ms
63,816 KB
testcase_45 AC 126 ms
53,472 KB
testcase_46 AC 79 ms
33,060 KB
testcase_47 AC 236 ms
56,612 KB
testcase_48 AC 82 ms
33,060 KB
testcase_49 AC 78 ms
33,060 KB
testcase_50 AC 77 ms
33,060 KB
testcase_51 AC 236 ms
56,612 KB
testcase_52 AC 81 ms
33,316 KB
testcase_53 AC 82 ms
33,316 KB
testcase_54 AC 236 ms
56,612 KB
testcase_55 AC 235 ms
56,612 KB
testcase_56 AC 79 ms
33,060 KB
testcase_57 AC 192 ms
56,612 KB
testcase_58 AC 125 ms
52,388 KB
testcase_59 AC 77 ms
32,804 KB
testcase_60 AC 78 ms
32,932 KB
testcase_61 AC 77 ms
32,804 KB
testcase_62 AC 155 ms
56,612 KB
testcase_63 AC 169 ms
56,612 KB
testcase_64 AC 80 ms
33,316 KB
testcase_65 AC 125 ms
52,644 KB
testcase_66 AC 78 ms
32,420 KB
testcase_67 AC 77 ms
179,560 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (105 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;
        if (n == 2 && a[0] != 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