結果

問題 No.2672 Subset Xor Sum
ユーザー kakel-san
提出日時 2024-03-15 21:42:57
言語 C#
(.NET 8.0.404)
結果
WA  
実行時間 -
コード長 1,305 bytes
コンパイル時間 9,222 ms
コンパイル使用メモリ 164,968 KB
実行使用メモリ 186,344 KB
最終ジャッジ日時 2024-09-30 00:37:48
合計ジャッジ時間 17,674 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 59 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (92 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 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];
        var all = a[0];
        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;
            all ^= a[i];
        }
        return all == 0 && dp2[0];
    }
}
 
0