結果

問題 No.2656 XOR Slimes
ユーザー tobisatistobisatis
提出日時 2024-03-01 21:29:05
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 2,134 bytes
コンパイル時間 13,649 ms
コンパイル使用メモリ 158,800 KB
実行使用メモリ 182,676 KB
最終ジャッジ日時 2024-03-01 21:29:28
合計ジャッジ時間 23,124 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
32,676 KB
testcase_01 AC 76 ms
32,676 KB
testcase_02 AC 75 ms
32,676 KB
testcase_03 AC 76 ms
32,676 KB
testcase_04 AC 74 ms
32,676 KB
testcase_05 AC 75 ms
32,676 KB
testcase_06 AC 75 ms
32,676 KB
testcase_07 AC 76 ms
32,676 KB
testcase_08 AC 119 ms
33,828 KB
testcase_09 AC 123 ms
33,828 KB
testcase_10 AC 114 ms
33,828 KB
testcase_11 AC 115 ms
33,828 KB
testcase_12 AC 113 ms
33,828 KB
testcase_13 AC 114 ms
33,828 KB
testcase_14 AC 114 ms
33,828 KB
testcase_15 AC 114 ms
33,828 KB
testcase_16 AC 115 ms
33,828 KB
testcase_17 AC 116 ms
33,828 KB
testcase_18 AC 143 ms
33,828 KB
testcase_19 AC 119 ms
33,828 KB
testcase_20 AC 115 ms
33,828 KB
testcase_21 AC 113 ms
33,828 KB
testcase_22 AC 114 ms
33,828 KB
testcase_23 AC 116 ms
33,828 KB
testcase_24 AC 115 ms
33,828 KB
testcase_25 AC 114 ms
33,828 KB
testcase_26 AC 114 ms
33,828 KB
testcase_27 AC 114 ms
33,828 KB
testcase_28 AC 118 ms
33,828 KB
testcase_29 AC 115 ms
33,956 KB
testcase_30 AC 115 ms
33,956 KB
testcase_31 AC 115 ms
33,956 KB
testcase_32 AC 116 ms
33,956 KB
testcase_33 AC 118 ms
33,956 KB
testcase_34 AC 114 ms
33,956 KB
testcase_35 AC 113 ms
33,956 KB
testcase_36 AC 116 ms
33,956 KB
testcase_37 AC 129 ms
33,956 KB
testcase_38 AC 115 ms
33,956 KB
testcase_39 AC 116 ms
33,956 KB
testcase_40 AC 115 ms
33,956 KB
testcase_41 AC 115 ms
33,956 KB
testcase_42 AC 115 ms
33,956 KB
testcase_43 AC 115 ms
34,084 KB
testcase_44 AC 115 ms
34,084 KB
testcase_45 AC 118 ms
34,084 KB
testcase_46 AC 115 ms
34,084 KB
testcase_47 AC 115 ms
34,084 KB
testcase_48 AC 117 ms
34,084 KB
testcase_49 AC 114 ms
34,084 KB
testcase_50 AC 113 ms
34,084 KB
testcase_51 AC 114 ms
34,084 KB
testcase_52 AC 116 ms
34,084 KB
testcase_53 AC 116 ms
34,084 KB
testcase_54 AC 114 ms
34,084 KB
testcase_55 AC 119 ms
34,084 KB
testcase_56 AC 116 ms
34,084 KB
testcase_57 AC 115 ms
34,084 KB
testcase_58 AC 116 ms
182,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (97 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 #

namespace AtCoder;

#nullable enable

using System.Numerics;

static class Extensions
{
    public static T[] Repeat<T>(this int time, Func<T> F) => Enumerable.Range(0, time).Select(_ => F()).ToArray();
}

class AtCoder
{
    object? Solve()
    {
        var n = Int();
        var xz = n.Repeat(Int);
        var az = n.Repeat(Int);
        var max = long.MaxValue / 8;
        var ans = new long[n + 1];
        for (var i = 1; i <= n; i++) ans[i] = max;
        ans[0] = 0;
        var sxorz = new int[n];
        sxorz[0] = az[0];
        for (var i = 1; i < n; i++) sxorz[i] = sxorz[i - 1] ^ az[i];
        for (var i = 0; i < n; i++)
        {
            for (var j = i; j < n; j++)
            {
                var xor = sxorz[j];
                if (i > 0) xor ^= sxorz[i - 1];
                ans[j + 1] = Math.Min(ans[j + 1], ans[i] + xz[j] - xz[i] + xor);
            }
        }
        return ans[n];
    }

    public static void Main() => new AtCoder().Run();
    public void Run()
    {
        var res = Solve();
        if (res != null)
        {
            if (res is bool yes) res = yes ? "Yes" : "No";
            sw.WriteLine(res);
        }
        sw.Flush();
    }

    string[] input = Array.Empty<string>();
    int iter = 0;
    readonly StreamWriter sw = new(Console.OpenStandardOutput()) { AutoFlush = false };

    #pragma warning disable IDE0051
    string String()
    {
        while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.Split(' '), 0);
        return input[iter++];
    }
    T Input<T>() where T : IParsable<T> => T.Parse(String(), null);
    int Int() => Input<int>();
    void Out(object? x, string? separator = null)
    {
        separator ??= Environment.NewLine;
        if (x is System.Collections.IEnumerable obj and not string)
        {
            var firstLine = true;
            foreach (var item in obj)
            {
                if (!firstLine) sw.Write(separator);
                firstLine = false;
                sw.Write(item);
            }
        }
        else sw.Write(x);
        sw.WriteLine();
    }
    #pragma warning restore IDE0051
}
0