結果

問題 No.971 いたずらっ子
ユーザー hedwig100hedwig100
提出日時 2020-04-15 21:47:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 444 ms / 2,000 ms
コード長 637 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 266,220 KB
最終ジャッジ日時 2024-04-25 02:13:02
合計ジャッジ時間 5,836 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 444 ms
266,220 KB
testcase_01 AC 442 ms
265,872 KB
testcase_02 AC 346 ms
212,608 KB
testcase_03 AC 412 ms
265,856 KB
testcase_04 AC 392 ms
248,320 KB
testcase_05 AC 410 ms
265,984 KB
testcase_06 AC 326 ms
211,328 KB
testcase_07 AC 63 ms
65,024 KB
testcase_08 AC 146 ms
123,648 KB
testcase_09 AC 144 ms
123,136 KB
testcase_10 AC 55 ms
62,976 KB
testcase_11 AC 47 ms
53,632 KB
testcase_12 AC 47 ms
53,632 KB
testcase_13 AC 52 ms
59,776 KB
testcase_14 AC 66 ms
65,920 KB
testcase_15 AC 51 ms
59,776 KB
testcase_16 AC 47 ms
54,016 KB
testcase_17 AC 46 ms
53,632 KB
testcase_18 AC 47 ms
53,760 KB
testcase_19 AC 47 ms
54,144 KB
testcase_20 AC 47 ms
53,504 KB
testcase_21 AC 46 ms
53,760 KB
testcase_22 AC 46 ms
53,632 KB
testcase_23 AC 46 ms
53,504 KB
testcase_24 AC 45 ms
53,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 10 ** 7
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from collections import deque

def main():
    h,w = map(int,input().split())
    grid = [list(input()) for _ in range(h)]

    dist = [[INF] * (w + 1) for _ in range(h + 1)]
    dist[0][1] = -1
    for i in range(h):
        for j in range(w):
            if grid[i][j] == 'k':
                dist[i + 1][j + 1] = min(dist[i][j + 1],dist[i + 1][j]) + i + j + 1
            else:
                dist[i + 1][j + 1] = min(dist[i][j + 1],dist[i + 1][j]) + 1

    print(dist[-1][-1])

if __name__ == '__main__':
    main()
0