結果

問題 No.1244 Black Segment
ユーザー 👑 tute7627tute7627
提出日時 2020-02-11 12:27:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 542 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 94,576 KB
最終ジャッジ日時 2024-04-17 02:09:24
合計ジャッジ時間 13,594 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
66,432 KB
testcase_01 AC 83 ms
66,432 KB
testcase_02 AC 83 ms
66,688 KB
testcase_03 AC 78 ms
66,816 KB
testcase_04 AC 80 ms
66,688 KB
testcase_05 AC 83 ms
66,944 KB
testcase_06 AC 79 ms
66,816 KB
testcase_07 AC 83 ms
66,944 KB
testcase_08 AC 86 ms
66,816 KB
testcase_09 AC 79 ms
66,816 KB
testcase_10 AC 78 ms
66,944 KB
testcase_11 AC 78 ms
66,688 KB
testcase_12 AC 80 ms
66,944 KB
testcase_13 AC 162 ms
79,744 KB
testcase_14 AC 365 ms
89,088 KB
testcase_15 AC 153 ms
79,744 KB
testcase_16 AC 340 ms
87,296 KB
testcase_17 AC 153 ms
79,104 KB
testcase_18 AC 384 ms
88,984 KB
testcase_19 AC 483 ms
91,964 KB
testcase_20 AC 465 ms
91,336 KB
testcase_21 AC 325 ms
89,740 KB
testcase_22 AC 523 ms
90,676 KB
testcase_23 AC 542 ms
92,324 KB
testcase_24 AC 467 ms
90,556 KB
testcase_25 AC 445 ms
90,652 KB
testcase_26 AC 465 ms
90,660 KB
testcase_27 AC 508 ms
92,160 KB
testcase_28 AC 485 ms
91,560 KB
testcase_29 AC 447 ms
90,536 KB
testcase_30 AC 469 ms
90,980 KB
testcase_31 AC 455 ms
91,032 KB
testcase_32 AC 446 ms
91,380 KB
testcase_33 AC 428 ms
90,608 KB
testcase_34 AC 333 ms
94,576 KB
testcase_35 AC 291 ms
89,604 KB
testcase_36 AC 435 ms
90,504 KB
testcase_37 AC 485 ms
93,840 KB
testcase_38 AC 445 ms
92,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import queue

n,m,a,b=map(int,input().split())
a-=1
g=[[] for i in range(n+1)]
for i in range(m):
    l,r=map(int,input().split())
    l-=1
    if l<a:l=a
    if r<a:r=a
    if l>b:l=b
    if r>b:r=b
    g[l].append(r)
    g[r].append(l)
que=queue.Queue()
que.put((a,0))
dist=[-1]*(n+1)
while(not que.empty()):
    p=que.get()
    if dist[p[0]]!=-1:continue
    dist[p[0]]=p[1]
    for to in g[p[0]]:
        que.put((to,p[1]+1))
print(dist[b])        
    
    
0