結果

問題 No.1244 Black Segment
ユーザー AEnAEn
提出日時 2023-03-28 15:32:31
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 81,604 KB
実行使用メモリ 87,900 KB
最終ジャッジ日時 2023-10-20 09:49:07
合計ジャッジ時間 7,748 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,312 KB
testcase_01 AC 41 ms
55,312 KB
testcase_02 AC 42 ms
55,312 KB
testcase_03 WA -
testcase_04 AC 41 ms
55,312 KB
testcase_05 WA -
testcase_06 AC 42 ms
55,312 KB
testcase_07 WA -
testcase_08 AC 42 ms
55,312 KB
testcase_09 AC 42 ms
55,312 KB
testcase_10 WA -
testcase_11 AC 43 ms
55,312 KB
testcase_12 AC 43 ms
55,312 KB
testcase_13 AC 90 ms
76,548 KB
testcase_14 AC 144 ms
77,812 KB
testcase_15 WA -
testcase_16 AC 124 ms
76,840 KB
testcase_17 AC 69 ms
72,692 KB
testcase_18 AC 165 ms
83,512 KB
testcase_19 AC 187 ms
85,356 KB
testcase_20 AC 191 ms
84,412 KB
testcase_21 AC 172 ms
84,164 KB
testcase_22 AC 195 ms
84,460 KB
testcase_23 WA -
testcase_24 AC 202 ms
84,956 KB
testcase_25 AC 188 ms
84,316 KB
testcase_26 AC 203 ms
85,784 KB
testcase_27 WA -
testcase_28 AC 204 ms
85,544 KB
testcase_29 AC 209 ms
86,468 KB
testcase_30 AC 192 ms
84,836 KB
testcase_31 AC 214 ms
86,588 KB
testcase_32 AC 221 ms
86,820 KB
testcase_33 AC 219 ms
86,648 KB
testcase_34 AC 128 ms
80,884 KB
testcase_35 AC 126 ms
80,692 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 201 ms
85,944 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())
    if (l<=A and r<=A) or (l>=B and r>=B):continue
    if l<=A:
        l = A
    if r>=B:
        r = B
    G[l].append(r+1)
    G[r+1].append(l)

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