結果

問題 No.1244 Black Segment
ユーザー ああいいああいい
提出日時 2022-02-19 17:03:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 268 ms / 2,000 ms
コード長 575 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 90,744 KB
最終ジャッジ日時 2023-09-11 20:44:48
合計ジャッジ時間 10,742 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,644 KB
testcase_01 AC 89 ms
71,560 KB
testcase_02 AC 90 ms
71,508 KB
testcase_03 AC 91 ms
71,456 KB
testcase_04 AC 93 ms
71,428 KB
testcase_05 AC 90 ms
71,576 KB
testcase_06 AC 91 ms
71,572 KB
testcase_07 AC 91 ms
71,560 KB
testcase_08 AC 93 ms
71,624 KB
testcase_09 AC 92 ms
71,568 KB
testcase_10 AC 91 ms
71,612 KB
testcase_11 AC 91 ms
71,624 KB
testcase_12 AC 92 ms
71,572 KB
testcase_13 AC 132 ms
78,824 KB
testcase_14 AC 201 ms
83,272 KB
testcase_15 AC 131 ms
78,692 KB
testcase_16 AC 198 ms
83,724 KB
testcase_17 AC 126 ms
79,220 KB
testcase_18 AC 213 ms
88,428 KB
testcase_19 AC 224 ms
86,220 KB
testcase_20 AC 244 ms
89,108 KB
testcase_21 AC 227 ms
89,236 KB
testcase_22 AC 246 ms
88,664 KB
testcase_23 AC 260 ms
88,956 KB
testcase_24 AC 245 ms
88,376 KB
testcase_25 AC 246 ms
90,744 KB
testcase_26 AC 243 ms
90,036 KB
testcase_27 AC 255 ms
90,056 KB
testcase_28 AC 253 ms
88,700 KB
testcase_29 AC 255 ms
89,348 KB
testcase_30 AC 252 ms
88,892 KB
testcase_31 AC 257 ms
89,260 KB
testcase_32 AC 257 ms
89,204 KB
testcase_33 AC 259 ms
89,568 KB
testcase_34 AC 268 ms
89,200 KB
testcase_35 AC 217 ms
87,060 KB
testcase_36 AC 240 ms
88,788 KB
testcase_37 AC 233 ms
87,692 KB
testcase_38 AC 256 ms
89,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,A,B = map(int,input().split())
G = [[] for _ in range(N+1)]
for _ in range(M):
    l,r = map(int,input().split())
    if l <= A:
        G[0].append(r)
    else:
        G[l-1].append(r)
        G[r].append(l-1)
inf = 10 ** 6
dist = [inf] * (N+1)
dist[0] = 0
from collections import deque
q = deque()
q.append(0)
while q:
    now = q.popleft()
    for v in G[now]:
        if dist[v] > dist[now] + 1:
            dist[v] = dist[now] + 1
            q.append(v)
ans = inf
for i in range(B,N+1):
    if dist[i] < ans:
        ans = dist[i]
print(ans if ans != inf else -1)
0