結果

問題 No.1702 count good string
ユーザー 👑 kakel-sankakel-san
提出日時 2023-12-30 19:45:09
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 1,337 bytes
コンパイル時間 7,078 ms
コンパイル使用メモリ 158,696 KB
実行使用メモリ 178,792 KB
最終ジャッジ日時 2023-12-30 19:45:22
合計ジャッジ時間 12,165 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
31,012 KB
testcase_01 AC 53 ms
31,012 KB
testcase_02 AC 53 ms
31,012 KB
testcase_03 AC 58 ms
31,012 KB
testcase_04 AC 53 ms
31,012 KB
testcase_05 AC 54 ms
31,012 KB
testcase_06 AC 54 ms
31,012 KB
testcase_07 AC 54 ms
31,012 KB
testcase_08 AC 54 ms
31,012 KB
testcase_09 AC 57 ms
31,012 KB
testcase_10 AC 53 ms
31,012 KB
testcase_11 AC 52 ms
31,012 KB
testcase_12 AC 62 ms
31,012 KB
testcase_13 AC 91 ms
51,364 KB
testcase_14 AC 91 ms
51,364 KB
testcase_15 AC 91 ms
51,364 KB
testcase_16 AC 91 ms
51,364 KB
testcase_17 AC 97 ms
51,364 KB
testcase_18 AC 91 ms
51,364 KB
testcase_19 AC 91 ms
51,364 KB
testcase_20 AC 90 ms
51,364 KB
testcase_21 AC 91 ms
51,364 KB
testcase_22 AC 91 ms
51,364 KB
testcase_23 AC 55 ms
31,268 KB
testcase_24 AC 56 ms
31,268 KB
testcase_25 AC 54 ms
31,268 KB
testcase_26 AC 54 ms
31,268 KB
testcase_27 AC 54 ms
31,268 KB
testcase_28 AC 54 ms
31,268 KB
testcase_29 AC 57 ms
31,268 KB
testcase_30 AC 55 ms
31,268 KB
testcase_31 AC 58 ms
31,268 KB
testcase_32 AC 53 ms
31,268 KB
testcase_33 AC 88 ms
51,364 KB
testcase_34 AC 88 ms
51,364 KB
testcase_35 AC 89 ms
51,364 KB
testcase_36 AC 91 ms
51,364 KB
testcase_37 AC 89 ms
51,364 KB
testcase_38 AC 89 ms
51,364 KB
testcase_39 AC 92 ms
51,364 KB
testcase_40 AC 89 ms
51,364 KB
testcase_41 AC 89 ms
51,364 KB
testcase_42 AC 89 ms
51,364 KB
testcase_43 AC 99 ms
51,364 KB
testcase_44 AC 91 ms
51,492 KB
testcase_45 AC 53 ms
31,012 KB
testcase_46 AC 53 ms
31,012 KB
testcase_47 AC 54 ms
31,012 KB
testcase_48 AC 53 ms
31,012 KB
testcase_49 AC 54 ms
178,792 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();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var s = ReadLine();
        var dp = new long[n + 1][];
        dp[0] = new long[18];
        var y = "yukicoder";
        var mod = 1_000_000_007;
        for (var i = 1; i < dp.Length; ++i)
        {
            dp[i] = (long[]) dp[i - 1].Clone();
            if (s[i - 1] == y[0])
            {
                dp[i][0] = (dp[i][0] + 1) % mod;
            }
            else if (s[i - 1] == '?')
            {
                dp[i][9] = (dp[i][9] + 1) % mod;
                for (var j = 1; j < y.Length; ++j)
                {
                    dp[i][j + 9] = (dp[i][j + 9] + dp[i - 1][j - 1]) % mod;
                }
            }
            else for (var j = 1; j < y.Length; ++j) if (s[i - 1] == y[j])
            {
                dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % mod;
                dp[i][j + 9] = (dp[i][j + 9] + dp[i - 1][j + 8]) % mod;
            }
        }
        WriteLine((dp[n][8] + dp[n][17]) % mod);
    }
}
0