結果

問題 No.971 いたずらっ子
ユーザー mkawa2mkawa2
提出日時 2020-01-17 21:51:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,149 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 141,736 KB
最終ジャッジ日時 2023-09-08 02:27:01
合計ジャッジ時間 7,218 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 354 ms
141,064 KB
testcase_06 AC 301 ms
127,580 KB
testcase_07 AC 111 ms
77,020 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 102 ms
77,140 KB
testcase_11 AC 91 ms
71,688 KB
testcase_12 AC 91 ms
71,684 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 96 ms
72,264 KB
testcase_17 AC 89 ms
71,628 KB
testcase_18 AC 92 ms
71,456 KB
testcase_19 AC 90 ms
71,648 KB
testcase_20 AC 93 ms
71,424 KB
testcase_21 AC 91 ms
71,552 KB
testcase_22 AC 94 ms
71,652 KB
testcase_23 AC 94 ms
71,624 KB
testcase_24 AC 94 ms
71,800 KB
権限があれば一括ダウンロードができます

ソースコード

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