結果

問題 No.971 いたずらっ子
ユーザー H3PO4H3PO4
提出日時 2021-07-26 09:25:20
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 379 ms / 2,000 ms
コード長 379 bytes
コンパイル時間 418 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 112,952 KB
最終ジャッジ日時 2023-08-07 08:10:52
合計ジャッジ時間 5,771 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 379 ms
112,952 KB
testcase_01 AC 375 ms
112,936 KB
testcase_02 AC 310 ms
104,564 KB
testcase_03 AC 305 ms
112,952 KB
testcase_04 AC 294 ms
110,912 KB
testcase_05 AC 291 ms
112,908 KB
testcase_06 AC 248 ms
104,756 KB
testcase_07 AC 86 ms
76,260 KB
testcase_08 AC 142 ms
86,280 KB
testcase_09 AC 139 ms
85,716 KB
testcase_10 AC 79 ms
76,316 KB
testcase_11 AC 71 ms
71,460 KB
testcase_12 AC 72 ms
71,320 KB
testcase_13 AC 76 ms
76,504 KB
testcase_14 AC 95 ms
77,056 KB
testcase_15 AC 76 ms
76,108 KB
testcase_16 AC 73 ms
71,552 KB
testcase_17 AC 71 ms
71,360 KB
testcase_18 AC 70 ms
71,324 KB
testcase_19 AC 71 ms
71,388 KB
testcase_20 AC 70 ms
71,228 KB
testcase_21 AC 72 ms
71,556 KB
testcase_22 AC 72 ms
71,264 KB
testcase_23 AC 74 ms
71,292 KB
testcase_24 AC 73 ms
71,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

H, W = map(int, input().split())
A = [input() for _ in range(H)]

INF = 10 ** 18

table = [[INF] * (W + 1) for _ in range(H + 1)]
table[1][1] = 0
it = itertools.product(range(H), range(W))
next(it)
for h, w in it:
    tmp = min(table[h][w + 1], table[h + 1][w]) + 1
    if A[h][w] == 'k':
        tmp += h + w
    table[h + 1][w + 1] = tmp
print(table[-1][-1])
0