結果

問題 No.1694 ZerOne
ユーザー 👑 kakel-sankakel-san
提出日時 2024-01-01 17:06:52
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 1,669 bytes
コンパイル時間 12,430 ms
コンパイル使用メモリ 158,048 KB
実行使用メモリ 189,376 KB
最終ジャッジ日時 2024-01-01 17:07:09
合計ジャッジ時間 16,937 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
29,220 KB
testcase_01 AC 51 ms
29,220 KB
testcase_02 AC 54 ms
29,220 KB
testcase_03 AC 64 ms
36,516 KB
testcase_04 AC 52 ms
29,220 KB
testcase_05 AC 54 ms
30,244 KB
testcase_06 AC 51 ms
29,220 KB
testcase_07 AC 53 ms
29,860 KB
testcase_08 AC 59 ms
30,884 KB
testcase_09 AC 68 ms
37,796 KB
testcase_10 AC 57 ms
29,604 KB
testcase_11 AC 51 ms
29,220 KB
testcase_12 AC 52 ms
29,220 KB
testcase_13 AC 55 ms
31,908 KB
testcase_14 AC 66 ms
38,052 KB
testcase_15 AC 53 ms
29,988 KB
testcase_16 AC 53 ms
30,116 KB
testcase_17 AC 52 ms
29,220 KB
testcase_18 AC 51 ms
29,220 KB
testcase_19 AC 51 ms
29,220 KB
testcase_20 AC 51 ms
29,220 KB
testcase_21 AC 98 ms
54,564 KB
testcase_22 AC 56 ms
29,220 KB
testcase_23 AC 98 ms
54,180 KB
testcase_24 AC 74 ms
43,044 KB
testcase_25 AC 73 ms
42,532 KB
testcase_26 AC 56 ms
29,220 KB
testcase_27 AC 87 ms
53,668 KB
testcase_28 AC 63 ms
37,412 KB
testcase_29 AC 59 ms
31,652 KB
testcase_30 AC 63 ms
36,516 KB
testcase_31 AC 68 ms
39,332 KB
testcase_32 AC 73 ms
43,684 KB
testcase_33 AC 74 ms
189,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 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[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var s = ReadLine();
        var sum = 0;
        var cnt = 0;
        for (var i = 0; i < s.Length; ++i) if (s[i] == '1')
        {
            sum += i;
            ++cnt;
        }
        if (cnt == 0)
        {
            WriteLine(1);
            return;
        }
        var dp = new long[sum + 1][];
        for (var i = 0; i < dp.Length; ++i) dp[i] = new long[s.Length];
        for (var i = 0; i <= sum && i < s.Length; ++i) dp[i][i] = 1;
        for (var i = 1; i < cnt; ++i)
        {
            var ndp = new long[sum + 1][];
            for (var j = 0; j < ndp.Length; ++j) ndp[j] = new long[s.Length];
            for (var j = sum - 1; j >= 0; --j) for (var k = s.Length - 1; k >= 0; --k)
            {
                if (dp[j][k] == 0) continue;
                for (var l = k + 1; l < s.Length && j + l <= sum; ++l)
                {
                    ndp[j + l][l] += dp[j][k];
                }
            }
            dp = ndp;
            // WriteLine(i);
            // WriteLine(string.Join("\n", dp.Select(di => string.Join(" ", di))));
        }
        var ans = 0L;
        for (var i = 0; i < s.Length; ++i) ans += dp[sum][i];
        WriteLine(ans);
    }
}
0