結果

問題 No.2672 Subset Xor Sum
ユーザー kakel-san
提出日時 2024-03-15 21:44:31
言語 C#
(.NET 8.0.404)
結果
WA  
実行時間 -
コード長 1,377 bytes
コンパイル時間 7,932 ms
コンパイル使用メモリ 167,492 KB
実行使用メモリ 185,592 KB
最終ジャッジ日時 2024-09-30 00:39:48
合計ジャッジ時間 15,868 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 65 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (121 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.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