結果
| 問題 | No.3504 Insert Maze |
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2026-08-19 22:59:53 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 619 bytes |
| 記録 | |
| コンパイル時間 | 822 ms |
| コンパイル使用メモリ | 95,804 KB |
| 実行使用メモリ | 155,008 KB |
| 最終ジャッジ日時 | 2026-08-19 23:00:25 |
| 合計ジャッジ時間 | 18,265 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 79 WA * 6 |
ソースコード
from collections import deque
INF = 1<<60
direction = [(-1,0),(0,1),(1,0),(0,-1)]
H, W = map(int, input().split())
S = [input() for _ in range(H)]
que = deque()
que.append((0, 0))
visited = [[INF]*W for _ in range(H)]
visited[0][0] = 0
MIN = 1<<60
while que:
h, w = que.popleft()
if H-2 <= h or W-2 <= w:
MIN = min(MIN, visited[h][w]-h-w)
for dh, dw in direction:
nh, nw = h+dh, w+dw
if 0<=nh<H and 0<=nw<W and S[nh][nw] != "#" and visited[nh][nw] == INF:
visited[nh][nw] = visited[h][w]+1
que.append((nh, nw))
print(min(visited[-1][-1], H+W-1+MIN, H+W))
detteiuu