結果
| 問題 | 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 |
| 記録 | |
| コンパイル時間 | 437 ms |
| コンパイル使用メモリ | 20,828 KB |
| 実行使用メモリ | 120,552 KB |
| 最終ジャッジ日時 | 2026-03-25 21:50:40 |
| 合計ジャッジ時間 | 125,442 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 TLE * 1 |
| 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)
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))