結果

問題 No.971 いたずらっ子
ユーザー mkawa2mkawa2
提出日時 2020-01-17 21:50:48
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
TLE  
実行時間 -
コード長 1,149 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 11,012 KB
実行使用メモリ 191,040 KB
最終ジャッジ日時 2023-09-08 02:26:22
合計ジャッジ時間 6,814 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]

def main():
    h,w=MI()
    inf=10**6
    t=[[c=="k" for c in input()] for _ in range(h)]
    dist=[[0]*w for _ in range(h)]
    for i in range(h):
        disti=dist[i]
        for j in range(w):
            if (i,j)==(0,0):continue
            d=inf
            if i-1>=0:d=min(d,disti1[j]+1)
            if j-1>=0:d=min(d,disti[j-1]+1)
            if t[i][j]:d+=i+j
            dist[i][j]=d
        disti1=disti
    #p2D(dist)
    print(dist[-1][-1])

main()
0