結果

問題 No.1382 Travel in Mitaru city
ユーザー H3PO4H3PO4
提出日時 2021-02-07 20:53:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 540 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 62,048 KB
最終ジャッジ日時 2023-09-17 19:42:23
合計ジャッジ時間 36,643 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 201 ms
42,912 KB
testcase_01 AC 201 ms
42,916 KB
testcase_02 AC 205 ms
43,220 KB
testcase_03 AC 205 ms
42,844 KB
testcase_04 AC 208 ms
42,788 KB
testcase_05 AC 207 ms
42,948 KB
testcase_06 WA -
testcase_07 AC 424 ms
50,092 KB
testcase_08 WA -
testcase_09 AC 543 ms
54,044 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 605 ms
59,868 KB
testcase_28 AC 599 ms
59,376 KB
testcase_29 AC 600 ms
59,736 KB
testcase_30 AC 599 ms
59,300 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 534 ms
56,916 KB
testcase_37 AC 257 ms
45,208 KB
testcase_38 AC 566 ms
58,456 KB
testcase_39 AC 300 ms
46,696 KB
testcase_40 AC 475 ms
54,292 KB
testcase_41 AC 513 ms
56,016 KB
testcase_42 AC 578 ms
58,456 KB
testcase_43 AC 522 ms
56,904 KB
testcase_44 AC 334 ms
48,532 KB
testcase_45 AC 490 ms
55,112 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 452 ms
53,180 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 AC 221 ms
43,512 KB
testcase_62 AC 206 ms
43,088 KB
testcase_63 AC 308 ms
43,568 KB
testcase_64 AC 237 ms
43,664 KB
testcase_65 AC 209 ms
42,772 KB
testcase_66 AC 219 ms
43,132 KB
testcase_67 AC 225 ms
43,152 KB
testcase_68 AC 250 ms
43,292 KB
testcase_69 AC 222 ms
43,136 KB
testcase_70 AC 256 ms
43,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

N, M, S, T = map(int, input().split())
S -= 1
T -= 1
P = tuple(map(int, input().split()))
frm, to = [0] * M, [0] * M
for i in range(M):
    a, b = (int(x) - 1 for x in input().split())
    frm[i] = a
    to[i] = b

matr = csr_matrix(([1] * M, (frm, to)), shape=(N, N))
p, labels = connected_components(matr, directed=False)

ls, ps = labels[S], P[S]
st = set()
for x, p in zip(labels, P):
    if x == ls and p < ps:
        st.add(p)
print(len(st))
0