結果

問題 No.1740 Alone 'a'
ユーザー 👑 kakel-sankakel-san
提出日時 2023-12-29 13:17:57
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 1,190 bytes
コンパイル時間 8,505 ms
コンパイル使用メモリ 158,420 KB
実行使用メモリ 181,428 KB
最終ジャッジ日時 2023-12-29 13:18:11
合計ジャッジ時間 13,425 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
31,140 KB
testcase_01 AC 53 ms
31,140 KB
testcase_02 AC 54 ms
31,140 KB
testcase_03 AC 80 ms
44,708 KB
testcase_04 AC 79 ms
44,708 KB
testcase_05 AC 60 ms
31,652 KB
testcase_06 AC 58 ms
31,524 KB
testcase_07 AC 53 ms
31,140 KB
testcase_08 AC 54 ms
31,140 KB
testcase_09 AC 54 ms
31,140 KB
testcase_10 AC 55 ms
31,140 KB
testcase_11 AC 59 ms
33,700 KB
testcase_12 AC 73 ms
42,148 KB
testcase_13 AC 73 ms
41,508 KB
testcase_14 AC 77 ms
44,068 KB
testcase_15 AC 55 ms
31,268 KB
testcase_16 AC 74 ms
41,124 KB
testcase_17 AC 54 ms
31,268 KB
testcase_18 AC 58 ms
32,932 KB
testcase_19 AC 74 ms
42,148 KB
testcase_20 AC 66 ms
37,028 KB
testcase_21 AC 74 ms
39,076 KB
testcase_22 AC 71 ms
40,612 KB
testcase_23 AC 71 ms
40,612 KB
testcase_24 AC 66 ms
37,028 KB
testcase_25 AC 66 ms
37,156 KB
testcase_26 AC 69 ms
38,948 KB
testcase_27 AC 70 ms
39,460 KB
testcase_28 AC 67 ms
38,052 KB
testcase_29 AC 77 ms
44,068 KB
testcase_30 AC 70 ms
39,332 KB
testcase_31 AC 74 ms
40,868 KB
testcase_32 AC 68 ms
38,180 KB
testcase_33 AC 73 ms
40,740 KB
testcase_34 AC 59 ms
33,188 KB
testcase_35 AC 67 ms
37,924 KB
testcase_36 AC 70 ms
36,772 KB
testcase_37 AC 59 ms
33,316 KB
testcase_38 AC 64 ms
35,748 KB
testcase_39 AC 58 ms
32,036 KB
testcase_40 AC 61 ms
181,428 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (139 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();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var s = ReadLine();
        var mod = 998_244_353;
        var dp = new long[n + 1][];
        for (var i = 0; i < dp.Length; ++i) dp[i] = new long[4];
        dp[0][2] = 1;
        for (var i = 0; i < n; ++i)
        {
            dp[i + 1][0] = (dp[i + 1][0] + dp[i][0] * 25) % mod;
            dp[i + 1][1] = (dp[i + 1][1] + dp[i][0] + dp[i][1] * 25) % mod;
            if (s[i] == 'a')
            {
                dp[i + 1][3] = dp[i][2];
            }
            else
            {
                dp[i + 1][0] = (dp[i + 1][0] + dp[i][2] * (s[i] - 'b')) % mod;
                dp[i + 1][1] = (dp[i + 1][1] + dp[i][2] + dp[i][3] * (s[i] - 'b')) % mod;
                dp[i + 1][2] = dp[i][2];
                dp[i + 1][3] = dp[i][3];
            }
        }
        WriteLine(dp[n][1]);
    }
}
0