結果

問題 No.2708 Jewel holder
ユーザー 👑 kakel-sankakel-san
提出日時 2024-04-09 23:19:31
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 1,316 bytes
コンパイル時間 9,317 ms
コンパイル使用メモリ 167,472 KB
実行使用メモリ 187,436 KB
最終ジャッジ日時 2024-04-09 23:19:48
合計ジャッジ時間 11,330 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
30,208 KB
testcase_01 AC 52 ms
30,208 KB
testcase_02 AC 50 ms
30,208 KB
testcase_03 AC 50 ms
30,464 KB
testcase_04 AC 50 ms
30,328 KB
testcase_05 AC 53 ms
30,208 KB
testcase_06 AC 54 ms
30,188 KB
testcase_07 AC 53 ms
30,080 KB
testcase_08 AC 55 ms
30,464 KB
testcase_09 AC 53 ms
30,188 KB
testcase_10 AC 55 ms
30,336 KB
testcase_11 AC 53 ms
30,464 KB
testcase_12 AC 59 ms
30,208 KB
testcase_13 AC 59 ms
30,592 KB
testcase_14 AC 59 ms
30,208 KB
testcase_15 AC 51 ms
30,464 KB
testcase_16 AC 49 ms
30,208 KB
testcase_17 AC 51 ms
30,464 KB
testcase_18 AC 51 ms
30,080 KB
testcase_19 AC 55 ms
187,436 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (127 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.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 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) = (c[0], c[1]);
        var map = SList(h);
        var dp = new int[h, w, 21];
        dp[0, 0, 1] = 1;
        for (var i = 0; i < h; ++i) for (var j = 0; j < w; ++j) for (var k = 0; k < 21; ++k)
        {
            if (i + 1 < h)
            {
                if (map[i + 1][j] == 'o' && k + 1 < 21) dp[i + 1, j, k + 1] += dp[i, j, k];
                else if (map[i + 1][j] == 'x' && k > 0) dp[i + 1, j, k - 1] += dp[i, j, k];
            }
            if (j + 1 < w)
            {
                if (map[i][j + 1] == 'o' && k + 1 < 21) dp[i, j + 1, k + 1] += dp[i, j, k];
                else if (map[i][j + 1] == 'x' && k > 0) dp[i, j + 1, k - 1] += dp[i, j, k];
            }
        }
        var ans = 0;
        for (var i = 0; i < 21; ++i) ans += dp[h - 1, w - 1, i];
        WriteLine(ans);
    }
}
0