結果

問題 No.1244 Black Segment
ユーザー 👑 rin204rin204
提出日時 2022-07-06 06:53:49
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 661 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 89,680 KB
最終ジャッジ日時 2023-08-22 22:11:20
合計ジャッジ時間 10,743 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,360 KB
testcase_01 AC 91 ms
71,564 KB
testcase_02 AC 93 ms
71,452 KB
testcase_03 AC 92 ms
71,512 KB
testcase_04 AC 93 ms
71,412 KB
testcase_05 WA -
testcase_06 AC 92 ms
71,372 KB
testcase_07 WA -
testcase_08 AC 92 ms
71,500 KB
testcase_09 AC 93 ms
71,416 KB
testcase_10 WA -
testcase_11 AC 91 ms
71,124 KB
testcase_12 AC 94 ms
71,368 KB
testcase_13 AC 134 ms
77,620 KB
testcase_14 AC 188 ms
79,780 KB
testcase_15 WA -
testcase_16 AC 174 ms
79,008 KB
testcase_17 AC 123 ms
77,800 KB
testcase_18 AC 99 ms
76,692 KB
testcase_19 AC 98 ms
76,424 KB
testcase_20 AC 225 ms
83,900 KB
testcase_21 AC 204 ms
84,772 KB
testcase_22 AC 224 ms
84,176 KB
testcase_23 WA -
testcase_24 AC 236 ms
85,296 KB
testcase_25 AC 220 ms
83,944 KB
testcase_26 AC 228 ms
86,652 KB
testcase_27 WA -
testcase_28 AC 236 ms
85,908 KB
testcase_29 AC 240 ms
87,880 KB
testcase_30 AC 223 ms
84,192 KB
testcase_31 AC 240 ms
86,872 KB
testcase_32 AC 248 ms
87,164 KB
testcase_33 AC 239 ms
86,380 KB
testcase_34 AC 91 ms
71,576 KB
testcase_35 AC 156 ms
77,620 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 98 ms
76,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n, m, a, b = map(int, input().split())
n = b - a + 2
edges = [[] for _ in range(n)]
for _ in range(m):
    l, r = map(int, input().split())
    if l <= a and b <= r:
        print(1)
        exit()
    elif r <= a or b <= l:
        pass
    else:
        l = max(l, a) - a
        r = min(r, b) - a + 1
        edges[l].append(r)
        edges[r].append(l)
        
queue = deque()
queue.append(0)
dist = [-1] * n
dist[0] = 0
while queue:
    pos = queue.popleft()
    for npos in edges[pos]:
        if dist[npos] != -1:
            continue
        dist[npos] = dist[pos] + 1
        queue.append(npos)
print(dist[-1])
        
0