結果

問題 No.1244 Black Segment
ユーザー 👑 tute7627tute7627
提出日時 2020-02-11 12:27:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,226 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 35,292 KB
最終ジャッジ日時 2024-04-17 02:08:51
合計ジャッジ時間 26,685 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
11,008 KB
testcase_01 AC 34 ms
10,880 KB
testcase_02 AC 34 ms
11,136 KB
testcase_03 AC 35 ms
10,880 KB
testcase_04 AC 33 ms
11,008 KB
testcase_05 AC 35 ms
11,008 KB
testcase_06 AC 35 ms
10,880 KB
testcase_07 AC 33 ms
10,880 KB
testcase_08 AC 34 ms
10,880 KB
testcase_09 AC 35 ms
11,136 KB
testcase_10 AC 33 ms
10,880 KB
testcase_11 AC 35 ms
11,008 KB
testcase_12 AC 33 ms
11,136 KB
testcase_13 AC 68 ms
11,648 KB
testcase_14 AC 1,128 ms
26,880 KB
testcase_15 AC 70 ms
11,776 KB
testcase_16 AC 1,057 ms
24,064 KB
testcase_17 AC 53 ms
11,776 KB
testcase_18 AC 691 ms
25,088 KB
testcase_19 AC 1,057 ms
28,032 KB
testcase_20 AC 1,006 ms
26,752 KB
testcase_21 AC 544 ms
26,620 KB
testcase_22 AC 1,132 ms
26,668 KB
testcase_23 AC 1,195 ms
30,592 KB
testcase_24 AC 1,220 ms
29,488 KB
testcase_25 AC 1,119 ms
29,184 KB
testcase_26 AC 1,092 ms
30,848 KB
testcase_27 AC 1,226 ms
31,616 KB
testcase_28 AC 1,171 ms
29,568 KB
testcase_29 AC 958 ms
28,800 KB
testcase_30 AC 1,194 ms
31,616 KB
testcase_31 AC 935 ms
29,440 KB
testcase_32 AC 978 ms
29,696 KB
testcase_33 AC 1,008 ms
30,080 KB
testcase_34 AC 1,105 ms
34,560 KB
testcase_35 AC 769 ms
27,420 KB
testcase_36 AC 1,155 ms
30,792 KB
testcase_37 AC 1,226 ms
35,292 KB
testcase_38 AC 1,220 ms
32,256 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