結果
| 問題 |
No.1382 Travel in Mitaru city
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-07 20:53:47 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 540 bytes |
| コンパイル時間 | 409 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 73,420 KB |
| 最終ジャッジ日時 | 2024-07-04 13:59:52 |
| 合計ジャッジ時間 | 87,417 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 WA * 38 |
ソースコード
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))