結果
| 問題 |
No.971 いたずらっ子
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2020-01-17 21:39:34 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,214 bytes |
| コンパイル時間 | 165 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 88,640 KB |
| 最終ジャッジ日時 | 2024-06-25 19:06:37 |
| 合計ジャッジ時間 | 6,989 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 4 |
| other | TLE * 1 -- * 20 |
ソースコード
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()
mkawa2