結果

問題 No.241 出席番号(1)
ユーザー H3PO4H3PO4
提出日時 2020-06-04 22:08:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 481 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 56,632 KB
最終ジャッジ日時 2024-05-07 14:39:47
合計ジャッジ時間 31,136 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 837 ms
56,252 KB
testcase_01 AC 846 ms
56,372 KB
testcase_02 AC 860 ms
56,120 KB
testcase_03 AC 862 ms
56,628 KB
testcase_04 AC 855 ms
56,508 KB
testcase_05 WA -
testcase_06 AC 869 ms
56,500 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 847 ms
56,372 KB
testcase_10 AC 837 ms
56,244 KB
testcase_11 AC 820 ms
56,116 KB
testcase_12 AC 841 ms
56,376 KB
testcase_13 AC 842 ms
56,340 KB
testcase_14 AC 825 ms
56,128 KB
testcase_15 AC 840 ms
56,500 KB
testcase_16 AC 836 ms
56,120 KB
testcase_17 WA -
testcase_18 AC 828 ms
56,376 KB
testcase_19 AC 827 ms
56,628 KB
testcase_20 AC 834 ms
56,628 KB
testcase_21 AC 839 ms
56,340 KB
testcase_22 AC 840 ms
56,372 KB
testcase_23 AC 845 ms
56,252 KB
testcase_24 AC 846 ms
56,380 KB
testcase_25 AC 847 ms
56,376 KB
testcase_26 AC 846 ms
56,372 KB
testcase_27 AC 846 ms
56,124 KB
testcase_28 AC 854 ms
56,500 KB
testcase_29 AC 867 ms
56,248 KB
testcase_30 AC 847 ms
56,632 KB
testcase_31 AC 858 ms
56,372 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)]

if len(set(A)) == 1:
    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