結果

問題 No.971 いたずらっ子
ユーザー daku9640daku9640
提出日時 2020-01-20 03:28:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 518 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 10,864 KB
実行使用メモリ 169,368 KB
最終ジャッジ日時 2023-09-15 20:39:08
合計ジャッジ時間 18,083 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 1,567 ms
128,996 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 AC 1,562 ms
168,300 KB
testcase_06 AC 1,208 ms
132,032 KB
testcase_07 AC 31 ms
9,284 KB
testcase_08 AC 568 ms
50,388 KB
testcase_09 AC 543 ms
48,392 KB
testcase_10 AC 29 ms
9,176 KB
testcase_11 AC 17 ms
7,768 KB
testcase_12 AC 17 ms
7,812 KB
testcase_13 AC 17 ms
8,308 KB
testcase_14 AC 23 ms
8,548 KB
testcase_15 AC 17 ms
8,240 KB
testcase_16 AC 17 ms
7,776 KB
testcase_17 AC 17 ms
7,780 KB
testcase_18 AC 16 ms
7,940 KB
testcase_19 AC 17 ms
7,860 KB
testcase_20 AC 16 ms
7,784 KB
testcase_21 AC 16 ms
7,828 KB
testcase_22 AC 17 ms
7,828 KB
testcase_23 AC 16 ms
7,712 KB
testcase_24 AC 16 ms
7,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = int(1e7)
def solve():
    H, W = map(int, input().split())
    dp = [[INF] * (W + 2) for _ in range(H + 2)]
    dp[0][1] = -1
    A = ["#" * (W + 2)] + ["#" + input() + "#" for _ in range(H)] + ["#" * (W + 2)]
    for i in range(1, H + 1):
        for j in range(1, W + 1):
            if A[i][j] == ".":
                dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1
            elif A[i][j] == "k":
                dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + (i - 1) + (j - 1) + 1
    print(dp[H][W])
solve()
0