結果
| 問題 | No.241 出席番号(1) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-04 22:12:52 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE 25/32
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 506 bytes |
| 記録 | |
| 最終ジャッジ日時 | 2024-11-30 08:18:11 |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
ソースコード
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import maximum_bipartite_matching
N = int(input())
A = [int(input()) for _ in range(N)]
st = set(A)
if len(st) == 1 and st.pop() < N:
print(-1)
exit()
frm, to = [], []
for i, a in enumerate(A):
for j in range(N):
if j == a:
continue
frm.append(i)
to.append(j)
matr = csr_matrix(([1] * len(frm), (frm, to)), shape=(N, N))
print(*maximum_bipartite_matching(matr, perm_type='column'), sep='\n')