結果
| 問題 | No.482 あなたの名は |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-25 09:59:43 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 1,694 ms / 2,000 ms |
| + 330µs | |
| コード長 | 420 bytes |
| 記録 | |
| コンパイル時間 | 517 ms |
| コンパイル使用メモリ | 21,540 KB |
| 実行使用メモリ | 84,388 KB |
| 最終ジャッジ日時 | 2026-07-20 09:38:45 |
| 合計ジャッジ時間 | 58,335 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
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')