結果
| 問題 | No.1382 Travel in Mitaru city |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-07 20:46:51 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 524 bytes |
| 記録 | |
| コンパイル時間 | 664 ms |
| コンパイル使用メモリ | 21,284 KB |
| 実行使用メモリ | 61,220 KB |
| 最終ジャッジ日時 | 2026-08-06 12:41:43 |
| 合計ジャッジ時間 | 7,456 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 1 -- * 2 |
| other | -- * 68 |
ソースコード
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)
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))