結果

問題 No.1244 Black Segment
ユーザー AEnAEn
提出日時 2023-03-28 15:37:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 257 ms / 2,000 ms
コード長 432 bytes
コンパイル時間 1,065 ms
コンパイル使用メモリ 81,636 KB
実行使用メモリ 90,356 KB
最終ジャッジ日時 2023-10-20 09:53:57
合計ジャッジ時間 8,615 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,476 KB
testcase_01 AC 43 ms
53,368 KB
testcase_02 AC 43 ms
55,416 KB
testcase_03 AC 43 ms
53,368 KB
testcase_04 AC 43 ms
55,416 KB
testcase_05 AC 43 ms
55,416 KB
testcase_06 AC 45 ms
55,416 KB
testcase_07 AC 44 ms
55,416 KB
testcase_08 AC 44 ms
55,416 KB
testcase_09 AC 43 ms
53,368 KB
testcase_10 AC 44 ms
55,416 KB
testcase_11 AC 44 ms
55,416 KB
testcase_12 AC 43 ms
55,416 KB
testcase_13 AC 95 ms
76,608 KB
testcase_14 AC 172 ms
80,492 KB
testcase_15 AC 93 ms
76,412 KB
testcase_16 AC 171 ms
81,184 KB
testcase_17 AC 89 ms
76,524 KB
testcase_18 AC 189 ms
85,328 KB
testcase_19 AC 217 ms
87,176 KB
testcase_20 AC 232 ms
86,916 KB
testcase_21 AC 214 ms
86,840 KB
testcase_22 AC 242 ms
86,980 KB
testcase_23 AC 250 ms
86,892 KB
testcase_24 AC 242 ms
87,036 KB
testcase_25 AC 245 ms
87,628 KB
testcase_26 AC 241 ms
87,200 KB
testcase_27 AC 231 ms
87,932 KB
testcase_28 AC 252 ms
87,976 KB
testcase_29 AC 248 ms
87,204 KB
testcase_30 AC 240 ms
87,500 KB
testcase_31 AC 250 ms
87,276 KB
testcase_32 AC 257 ms
87,464 KB
testcase_33 AC 249 ms
87,228 KB
testcase_34 AC 212 ms
87,728 KB
testcase_35 AC 200 ms
90,356 KB
testcase_36 AC 238 ms
89,824 KB
testcase_37 AC 223 ms
86,856 KB
testcase_38 AC 226 ms
86,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque


N,M,A,B = map(int, input().split())

G = [list() for _ in range(N+2)]
for i in range(M):
    l,r = map(int, input().split())
    G[max(l,A)].append(min(r+1,B+1))
    G[min(r+1,B+1)].append(max(l,A))

dis = [-1]*(N+2)
dis[A] = 0
d = deque()
d.append(A)
while d:
    v = d.popleft()
    for nex in G[v]:
        if dis[nex]==-1:
            dis[nex] = dis[v]+1
            d.append(nex)
print(dis[B+1])
0