結果

問題 No.971 いたずらっ子
ユーザー hedwig100hedwig100
提出日時 2020-04-15 21:47:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 637 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 199,296 KB
最終ジャッジ日時 2024-04-09 19:00:55
合計ジャッジ時間 20,287 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 1,773 ms
151,936 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 TLE -
testcase_06 AC 1,599 ms
155,648 KB
testcase_07 AC 42 ms
12,160 KB
testcase_08 AC 632 ms
60,032 KB
testcase_09 AC 601 ms
58,112 KB
testcase_10 AC 42 ms
12,288 KB
testcase_11 AC 25 ms
10,624 KB
testcase_12 AC 26 ms
10,752 KB
testcase_13 AC 28 ms
11,008 KB
testcase_14 AC 32 ms
11,392 KB
testcase_15 AC 29 ms
11,008 KB
testcase_16 AC 28 ms
10,624 KB
testcase_17 AC 28 ms
10,752 KB
testcase_18 AC 28 ms
10,752 KB
testcase_19 AC 27 ms
10,752 KB
testcase_20 AC 28 ms
10,752 KB
testcase_21 AC 28 ms
10,624 KB
testcase_22 AC 27 ms
10,624 KB
testcase_23 AC 27 ms
10,624 KB
testcase_24 AC 26 ms
10,752 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