結果

問題 No.2430 Damage Zone
ユーザー 👑 kakel-sankakel-san
提出日時 2023-08-18 22:16:47
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 1,727 bytes
コンパイル時間 2,268 ms
コンパイル使用メモリ 65,788 KB
実行使用メモリ 41,212 KB
最終ジャッジ日時 2023-08-18 22:16:54
合計ジャッジ時間 6,274 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
37,996 KB
testcase_01 AC 94 ms
31,788 KB
testcase_02 AC 149 ms
40,104 KB
testcase_03 AC 63 ms
21,844 KB
testcase_04 AC 64 ms
21,796 KB
testcase_05 AC 64 ms
21,828 KB
testcase_06 AC 61 ms
21,880 KB
testcase_07 AC 59 ms
21,856 KB
testcase_08 AC 60 ms
23,868 KB
testcase_09 AC 59 ms
21,852 KB
testcase_10 AC 60 ms
23,936 KB
testcase_11 AC 62 ms
21,800 KB
testcase_12 AC 64 ms
23,776 KB
testcase_13 AC 59 ms
21,856 KB
testcase_14 AC 156 ms
41,152 KB
testcase_15 AC 151 ms
41,184 KB
testcase_16 AC 146 ms
41,212 KB
testcase_17 AC 74 ms
23,832 KB
testcase_18 AC 63 ms
21,936 KB
testcase_19 AC 59 ms
21,976 KB
testcase_20 AC 94 ms
32,420 KB
testcase_21 AC 62 ms
21,848 KB
testcase_22 AC 59 ms
21,844 KB
testcase_23 AC 58 ms
19,892 KB
testcase_24 AC 61 ms
23,868 KB
testcase_25 AC 92 ms
29,800 KB
testcase_26 AC 96 ms
32,304 KB
testcase_27 AC 73 ms
23,892 KB
権限があれば一括ダウンロードができます

ソースコード

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();
    static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (h, w, k) = (c[0], c[1], c[2]);
        var s = SList(h);
        var dp = new long[h][][];
        for (var i = 0; i < dp.Length; ++i)
        {
            dp[i] = new long[w][];
            for (var j = 0; j < dp[i].Length; ++j) dp[i][j] = new long[k];
        }
        dp[0][0][k - 1] = 1;
        var mod = 998_244_353;
        for (var i = 0; i < h; ++i) for (var j = 0; j < w; ++j) for (var p = 0; p < k; ++p)
        {
            if (i + 1 < h)
            {
                if (s[i + 1][j] == '.') dp[i + 1][j][p] = (dp[i + 1][j][p] + dp[i][j][p]) % mod;
                else if (s[i + 1][j] == 'o' && p > 0) dp[i + 1][j][p - 1] = (dp[i + 1][j][p - 1] + dp[i][j][p]) % mod;
            }
            if (j + 1 < w)
            {
                if (s[i][j + 1] == '.') dp[i][j + 1][p] = (dp[i][j + 1][p] + dp[i][j][p]) % mod;
                else if (s[i][j + 1] == 'o' && p > 0) dp[i][j + 1][p - 1] = (dp[i][j + 1][p - 1] + dp[i][j][p]) % mod;
            }
        }
        var ans = 0L;
        for (var i = 0; i < dp[h - 1][w - 1].Length; ++i) ans = (ans + dp[h - 1][w - 1][i]) % mod;
        WriteLine(ans);
    }
}
0