結果

問題 No.2279 OR Insertion
ユーザー 👑 kakel-sankakel-san
提出日時 2023-12-07 23:27:49
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 727 ms / 2,000 ms
コード長 1,376 bytes
コンパイル時間 6,645 ms
コンパイル使用メモリ 158,576 KB
実行使用メモリ 305,748 KB
最終ジャッジ日時 2023-12-07 23:28:14
合計ジャッジ時間 22,853 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
30,884 KB
testcase_01 AC 54 ms
30,884 KB
testcase_02 AC 94 ms
45,988 KB
testcase_03 AC 72 ms
37,796 KB
testcase_04 AC 424 ms
145,004 KB
testcase_05 AC 61 ms
32,804 KB
testcase_06 AC 214 ms
76,452 KB
testcase_07 AC 206 ms
81,696 KB
testcase_08 AC 97 ms
46,756 KB
testcase_09 AC 258 ms
96,648 KB
testcase_10 AC 436 ms
141,724 KB
testcase_11 AC 87 ms
43,556 KB
testcase_12 AC 329 ms
117,812 KB
testcase_13 AC 69 ms
36,004 KB
testcase_14 AC 71 ms
37,412 KB
testcase_15 AC 224 ms
85,244 KB
testcase_16 AC 58 ms
31,908 KB
testcase_17 AC 192 ms
75,556 KB
testcase_18 AC 331 ms
106,724 KB
testcase_19 AC 384 ms
130,224 KB
testcase_20 AC 212 ms
81,680 KB
testcase_21 AC 163 ms
67,620 KB
testcase_22 AC 55 ms
30,884 KB
testcase_23 AC 54 ms
30,884 KB
testcase_24 AC 54 ms
31,012 KB
testcase_25 AC 59 ms
31,012 KB
testcase_26 AC 54 ms
31,012 KB
testcase_27 AC 53 ms
31,012 KB
testcase_28 AC 54 ms
31,012 KB
testcase_29 AC 54 ms
31,012 KB
testcase_30 AC 54 ms
31,012 KB
testcase_31 AC 54 ms
31,012 KB
testcase_32 AC 488 ms
158,068 KB
testcase_33 AC 510 ms
158,068 KB
testcase_34 AC 482 ms
158,068 KB
testcase_35 AC 499 ms
158,068 KB
testcase_36 AC 485 ms
158,068 KB
testcase_37 AC 472 ms
158,068 KB
testcase_38 AC 501 ms
158,068 KB
testcase_39 AC 471 ms
158,068 KB
testcase_40 AC 507 ms
158,068 KB
testcase_41 AC 508 ms
158,068 KB
testcase_42 AC 714 ms
158,068 KB
testcase_43 AC 689 ms
158,068 KB
testcase_44 AC 718 ms
158,068 KB
testcase_45 AC 305 ms
158,068 KB
testcase_46 AC 305 ms
158,068 KB
testcase_47 AC 306 ms
158,068 KB
testcase_48 AC 727 ms
158,068 KB
testcase_49 AC 273 ms
305,748 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (93 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 n = NN;
        var s = ReadLine();
        var mod = 998_244_353;
        var a = new long[n];
        a[0] = 1;
        for (var i = 1; i < n; ++i) a[i] = a[i - 1] * 2 % mod;
        var dp = new long[n][];
        for (var i = 0; i < n; ++i)
        {
            dp[i] = new long[n];
            if (i == 0)
            {
                dp[i][0] = s[0] - '0';
            }
            else
            {
                for (var j = 0; j <= i; ++j)
                {
                    if (s[i - j] == '0') dp[i][j] = dp[i - 1][j];
                    else dp[i][j] = (a[i - j] + dp[i - 1][j] - (i > j ? dp[i - j - 1][j] : 0) + mod) % mod;
                    if (i + 1 < n) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
                }
            }
        }
        var ans = 0L;
        for (var j = 0; j < n; ++j) ans = (ans + dp[n - 1][j] * a[j] % mod) % mod;
        WriteLine(ans);
    }
}
0