結果

問題 No.241 出席番号(1)
ユーザー H3PO4H3PO4
提出日時 2020-06-04 22:12:52
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 999 ms / 2,000 ms
コード長 506 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 56,392 KB
最終ジャッジ日時 2024-05-07 14:46:40
合計ジャッジ時間 32,794 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 888 ms
56,264 KB
testcase_01 AC 892 ms
56,140 KB
testcase_02 AC 879 ms
56,128 KB
testcase_03 AC 879 ms
55,884 KB
testcase_04 AC 879 ms
56,268 KB
testcase_05 AC 874 ms
56,132 KB
testcase_06 AC 878 ms
56,260 KB
testcase_07 AC 878 ms
56,272 KB
testcase_08 AC 887 ms
56,140 KB
testcase_09 AC 879 ms
56,268 KB
testcase_10 AC 882 ms
56,020 KB
testcase_11 AC 878 ms
55,760 KB
testcase_12 AC 879 ms
56,392 KB
testcase_13 AC 884 ms
56,012 KB
testcase_14 AC 898 ms
56,136 KB
testcase_15 AC 883 ms
56,004 KB
testcase_16 AC 880 ms
55,876 KB
testcase_17 AC 881 ms
55,884 KB
testcase_18 AC 875 ms
56,004 KB
testcase_19 AC 894 ms
56,136 KB
testcase_20 AC 883 ms
56,352 KB
testcase_21 AC 885 ms
56,392 KB
testcase_22 AC 896 ms
56,268 KB
testcase_23 AC 890 ms
56,148 KB
testcase_24 AC 887 ms
56,004 KB
testcase_25 AC 999 ms
56,008 KB
testcase_26 AC 897 ms
56,392 KB
testcase_27 AC 889 ms
55,492 KB
testcase_28 AC 888 ms
56,136 KB
testcase_29 AC 904 ms
56,128 KB
testcase_30 AC 892 ms
55,884 KB
testcase_31 AC 877 ms
56,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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')
0