結果

問題 No.971 いたずらっ子
ユーザー daku9640daku9640
提出日時 2020-01-20 03:30:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 518 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 111,488 KB
最終ジャッジ日時 2024-04-25 02:09:53
合計ジャッジ時間 4,132 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 243 ms
111,232 KB
testcase_01 AC 245 ms
111,232 KB
testcase_02 AC 209 ms
101,120 KB
testcase_03 AC 230 ms
111,488 KB
testcase_04 AC 221 ms
109,184 KB
testcase_05 AC 205 ms
111,232 KB
testcase_06 AC 176 ms
102,144 KB
testcase_07 AC 57 ms
62,464 KB
testcase_08 AC 97 ms
84,864 KB
testcase_09 AC 95 ms
84,608 KB
testcase_10 AC 50 ms
59,904 KB
testcase_11 AC 40 ms
51,712 KB
testcase_12 AC 40 ms
52,096 KB
testcase_13 AC 47 ms
58,240 KB
testcase_14 AC 83 ms
71,424 KB
testcase_15 AC 46 ms
58,624 KB
testcase_16 AC 46 ms
53,248 KB
testcase_17 AC 41 ms
51,840 KB
testcase_18 AC 40 ms
51,968 KB
testcase_19 AC 41 ms
51,840 KB
testcase_20 AC 41 ms
51,968 KB
testcase_21 AC 42 ms
52,096 KB
testcase_22 AC 41 ms
51,840 KB
testcase_23 AC 40 ms
52,096 KB
testcase_24 AC 41 ms
51,968 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