結果

問題 No.971 いたずらっ子
ユーザー mkawa2mkawa2
提出日時 2020-01-17 21:55:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 406 ms / 2,000 ms
コード長 1,185 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 140,544 KB
最終ジャッジ日時 2024-04-25 02:00:47
合計ジャッジ時間 5,362 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 406 ms
140,032 KB
testcase_01 AC 401 ms
140,288 KB
testcase_02 AC 328 ms
124,032 KB
testcase_03 AC 308 ms
140,544 KB
testcase_04 AC 289 ms
136,192 KB
testcase_05 AC 302 ms
140,032 KB
testcase_06 AC 258 ms
125,312 KB
testcase_07 AC 71 ms
67,200 KB
testcase_08 AC 126 ms
91,776 KB
testcase_09 AC 123 ms
92,160 KB
testcase_10 AC 59 ms
64,768 KB
testcase_11 AC 48 ms
54,656 KB
testcase_12 AC 48 ms
54,656 KB
testcase_13 AC 56 ms
61,056 KB
testcase_14 AC 100 ms
77,568 KB
testcase_15 AC 55 ms
60,800 KB
testcase_16 AC 54 ms
55,808 KB
testcase_17 AC 47 ms
54,400 KB
testcase_18 AC 49 ms
54,272 KB
testcase_19 AC 49 ms
54,400 KB
testcase_20 AC 47 ms
54,400 KB
testcase_21 AC 47 ms
54,912 KB
testcase_22 AC 49 ms
54,912 KB
testcase_23 AC 46 ms
54,400 KB
testcase_24 AC 49 ms
54,272 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**18
    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]
        ti=t[i]
        for j in range(w):
            if (i,j)==(0,0):continue
            d=inf
            if i-1>=0 and disti1[j]+1<d:d=disti1[j]+1
            if j-1>=0 and disti[j-1]+1<d:d=disti[j-1]+1
            if ti[j]:d+=i+j
            disti[j]=d
        disti1=disti
    #p2D(dist)
    print(dist[-1][-1])

main()
0