結果

問題 No.971 いたずらっ子
ユーザー mkawa2mkawa2
提出日時 2020-01-17 21:40:13
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,214 bytes
コンパイル時間 556 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 180,584 KB
最終ジャッジ日時 2023-09-08 02:02:15
合計ジャッジ時間 7,539 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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()
    t=[[c=="k" for c in input()] for _ in range(h)]
    vis=[[False]*w for _ in range(h)]
    hp=[]
    heappush(hp,(0,0,0))
    while hp:
        d,i,j=heappop(hp)
        if vis[i][j]:continue
        vis[i][j]=True
        if (i,j)==(h-1,w-1):
            print(d)
            exit()
        for ni,nj in [(i+1,j),(i,j+1)]:
            if ni>=h or nj>=w:continue
            if vis[ni][nj]:continue
            nd=d+1
            if t[ni][nj]:nd=d+ni+nj+1
            heappush(hp,(nd,ni,nj))

main()
0