結果

問題 No.1244 Black Segment
ユーザー 👑 tamatotamato
提出日時 2020-10-02 22:57:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 328 ms / 2,000 ms
コード長 870 bytes
コンパイル時間 912 ms
コンパイル使用メモリ 87,412 KB
実行使用メモリ 122,220 KB
最終ジャッジ日時 2023-09-24 22:34:40
合計ジャッジ時間 11,330 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
72,148 KB
testcase_01 AC 99 ms
72,148 KB
testcase_02 AC 102 ms
71,920 KB
testcase_03 AC 103 ms
71,792 KB
testcase_04 AC 105 ms
71,800 KB
testcase_05 AC 104 ms
72,220 KB
testcase_06 AC 101 ms
72,080 KB
testcase_07 AC 102 ms
71,956 KB
testcase_08 AC 102 ms
71,732 KB
testcase_09 AC 104 ms
71,828 KB
testcase_10 AC 105 ms
72,072 KB
testcase_11 AC 102 ms
72,100 KB
testcase_12 AC 104 ms
72,048 KB
testcase_13 AC 139 ms
77,812 KB
testcase_14 AC 194 ms
83,244 KB
testcase_15 AC 133 ms
78,124 KB
testcase_16 AC 174 ms
80,120 KB
testcase_17 AC 125 ms
78,024 KB
testcase_18 AC 249 ms
101,560 KB
testcase_19 AC 286 ms
102,100 KB
testcase_20 AC 301 ms
107,812 KB
testcase_21 AC 250 ms
99,732 KB
testcase_22 AC 314 ms
108,596 KB
testcase_23 AC 323 ms
110,516 KB
testcase_24 AC 306 ms
110,844 KB
testcase_25 AC 299 ms
110,332 KB
testcase_26 AC 298 ms
111,128 KB
testcase_27 AC 284 ms
118,976 KB
testcase_28 AC 317 ms
112,772 KB
testcase_29 AC 304 ms
110,928 KB
testcase_30 AC 309 ms
112,156 KB
testcase_31 AC 320 ms
110,552 KB
testcase_32 AC 321 ms
111,868 KB
testcase_33 AC 328 ms
111,708 KB
testcase_34 AC 244 ms
106,016 KB
testcase_35 AC 256 ms
121,564 KB
testcase_36 AC 300 ms
122,220 KB
testcase_37 AC 280 ms
108,512 KB
testcase_38 AC 280 ms
106,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import deque
    input = sys.stdin.buffer.readline

    N, M, A, B = map(int, input().split())
    N += 1
    adj = [set() for _ in range(N+1)]
    for _ in range(M):
        l, r = map(int, input().split())
        r += 1
        l = max(l, A)
        r = min(r, B+1)
        adj[l].add(r)
        adj[r].add(l)

    que = deque()
    que.append(A)
    seen = [-1] * (N+1)
    seen[A] = 0
    par = [0] * (N+1)
    child = [[] for _ in range(N+1)]
    seq = []
    while que:
        v = que.popleft()
        seq.append(v)
        for u in adj[v]:
            if seen[u] == -1:
                seen[u] = seen[v] + 1
                par[u] = v
                child[v].append(u)
                que.append(u)
    seq.reverse()

    print(seen[B+1])


if __name__ == '__main__':
    main()
0