結果

問題 No.482 あなたの名は
ユーザー H3PO4H3PO4
提出日時 2020-08-25 09:59:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,464 ms / 2,000 ms
コード長 420 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 106,824 KB
最終ジャッジ日時 2024-04-24 04:14:34
合計ジャッジ時間 38,907 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,464 ms
56,356 KB
testcase_01 AC 930 ms
56,364 KB
testcase_02 AC 962 ms
56,228 KB
testcase_03 AC 950 ms
56,244 KB
testcase_04 AC 935 ms
56,376 KB
testcase_05 AC 932 ms
56,488 KB
testcase_06 AC 942 ms
56,484 KB
testcase_07 AC 936 ms
56,228 KB
testcase_08 AC 923 ms
56,236 KB
testcase_09 AC 937 ms
56,356 KB
testcase_10 AC 933 ms
56,616 KB
testcase_11 AC 940 ms
56,492 KB
testcase_12 AC 952 ms
56,488 KB
testcase_13 AC 937 ms
56,360 KB
testcase_14 AC 937 ms
56,496 KB
testcase_15 AC 1,192 ms
73,628 KB
testcase_16 AC 1,245 ms
73,240 KB
testcase_17 AC 1,215 ms
73,492 KB
testcase_18 AC 1,226 ms
73,632 KB
testcase_19 AC 1,272 ms
73,368 KB
testcase_20 AC 1,230 ms
73,828 KB
testcase_21 AC 1,250 ms
73,496 KB
testcase_22 AC 1,276 ms
73,624 KB
testcase_23 AC 1,299 ms
73,528 KB
testcase_24 AC 1,249 ms
73,252 KB
testcase_25 AC 1,200 ms
73,492 KB
testcase_26 AC 1,198 ms
73,496 KB
testcase_27 AC 1,169 ms
73,488 KB
testcase_28 AC 1,148 ms
73,716 KB
testcase_29 AC 1,104 ms
73,620 KB
testcase_30 AC 816 ms
106,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

int1 = lambda x: int(x) - 1

N, K = map(int, input().split())
D = tuple(map(int1, input().split()))

matr = csr_matrix(([1] * N, (D, range(N))), shape=(N, N))
p = connected_components(matr, connection='strong', return_labels=False)
surplus_swap = K - (N - p)
print('YES' if surplus_swap >= 0 and surplus_swap % 2 == 0 else 'NO')
0