結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:08:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 99 ms / 2,000 ms |
| コード長 | 542 bytes |
| コンパイル時間 | 172 ms |
| コンパイル使用メモリ | 82,300 KB |
| 実行使用メモリ | 108,348 KB |
| 最終ジャッジ日時 | 2025-03-20 21:08:57 |
| 合計ジャッジ時間 | 3,240 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
N, K = map(int, input().split())
D = list(map(int, input().split()))
visited = [False] * (N + 1) # 1-based indexing
s_min = 0
for i in range(1, N + 1):
if not visited[i]:
cycle_length = 0
current = i
while not visited[current]:
visited[current] = True
current = D[current - 1] # D is 0-based list for 1-based elements
cycle_length += 1
s_min += (cycle_length - 1)
# Check the conditions
if K >= s_min and (K - s_min) % 2 == 0:
print("YES")
else:
print("NO")
lam6er