結果

問題 No.2695 Warp Zone
ユーザー nikoro256nikoro256
提出日時 2024-03-22 22:30:57
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 790 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 847,384 KB
最終ジャッジ日時 2024-03-22 22:30:59
合計ジャッジ時間 2,060 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,608 KB
testcase_01 MLE -
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 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
def bfs(s):
    dq=deque()
    dq.append([s,0])
    high=[10**9 for _ in range(H*W)]
    high[s]=0
    while len(dq)!=0:
        p,h=dq.popleft()
        for e in edge[p]:
            if  high[e]==10**9:
                dq.append([e,h+1])
                high[e]=h+1
    return high

def csv(i,j):
    return i*W+j

H,W,N=map(int,input().split())
edge=[[] for _ in range(H*W)]
for i in range(H-1):
    for j in range(W):
        edge[csv(i,j)].append(csv(i+1,j))
        edge[csv(i+1,j)].append(csv(i,j))
for i in range(H):
    for j in range(W-1):
        edge[csv(i,j)].append(csv(i,j+1))
        edge[csv(i,j+1)].append(csv(i,j))
for i in range(N):
    a,b,c,d=map(int,input().split())
    edge[csv(a-1,b-1)].append(csv(c-1,d-1))
dist=bfs(0)
print(dist[-1])
0