結果

問題 No.2430 Damage Zone
ユーザー 👑 kakel-sankakel-san
提出日時 2023-08-18 22:16:47
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 1,727 bytes
コンパイル時間 3,605 ms
コンパイル使用メモリ 108,032 KB
実行使用メモリ 36,736 KB
最終ジャッジ日時 2024-05-06 04:27:07
合計ジャッジ時間 3,977 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
32,640 KB
testcase_01 AC 54 ms
26,496 KB
testcase_02 AC 111 ms
36,736 KB
testcase_03 AC 27 ms
19,200 KB
testcase_04 AC 29 ms
19,584 KB
testcase_05 AC 28 ms
19,584 KB
testcase_06 AC 26 ms
18,816 KB
testcase_07 AC 25 ms
18,816 KB
testcase_08 AC 25 ms
18,816 KB
testcase_09 AC 26 ms
18,944 KB
testcase_10 AC 26 ms
19,200 KB
testcase_11 AC 28 ms
19,584 KB
testcase_12 AC 28 ms
19,328 KB
testcase_13 AC 27 ms
18,944 KB
testcase_14 AC 107 ms
35,712 KB
testcase_15 AC 108 ms
35,840 KB
testcase_16 AC 108 ms
35,968 KB
testcase_17 AC 41 ms
22,272 KB
testcase_18 AC 30 ms
19,712 KB
testcase_19 AC 25 ms
18,816 KB
testcase_20 AC 60 ms
27,136 KB
testcase_21 AC 28 ms
19,328 KB
testcase_22 AC 27 ms
19,328 KB
testcase_23 AC 29 ms
19,456 KB
testcase_24 AC 26 ms
19,584 KB
testcase_25 AC 51 ms
26,240 KB
testcase_26 AC 61 ms
27,392 KB
testcase_27 AC 42 ms
22,656 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

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