結果

問題 No.1244 Black Segment
ユーザー ntudantuda
提出日時 2021-11-09 21:55:09
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 681 bytes
コンパイル時間 1,376 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 99,536 KB
最終ジャッジ日時 2023-08-12 05:57:20
合計ジャッジ時間 12,514 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,100 KB
testcase_01 AC 69 ms
70,984 KB
testcase_02 AC 69 ms
71,080 KB
testcase_03 AC 72 ms
71,088 KB
testcase_04 RE -
testcase_05 WA -
testcase_06 RE -
testcase_07 WA -
testcase_08 RE -
testcase_09 AC 72 ms
71,168 KB
testcase_10 RE -
testcase_11 AC 72 ms
71,148 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 250 ms
99,536 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 AC 207 ms
92,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

N,M,A,B = map(int,input().split())
LR = [list(map(int,input().split())) for _ in range(M)]
E = [[] for _ in range(B - A + 2)]
N2 = B - A + 1
for i in range(M):
    l,r = LR[i]
    a = max(0,l-A)
    b = min(B-A+1,r-A+1)
    E[a].append((b))
    E[b].append((a))
#print(E)
q1 = {0}
q2 = set()
nvstd = [True] * (N2+1)
nvstd[0] = False
ans = 0
while q1:
    ans += 1
    while q1:
        frm = next(iter(q1))
        q1.remove(frm)
        for to in E[frm]:
            if to == N2:
                print(ans)
                sys.exit()

            if nvstd[to]:
                q2.add(to)
                nvstd[to] = False

    q1,q2 = q2,q1
    q2 = set()

print(-1)

0