結果
| 問題 | No.482 あなたの名は |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-30 12:40:10 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 78 ms / 2,000 ms |
| コード長 | 433 bytes |
| 記録 | |
| コンパイル時間 | 194 ms |
| コンパイル使用メモリ | 85,828 KB |
| 実行使用メモリ | 120,904 KB |
| 最終ジャッジ日時 | 2026-03-04 10:19:08 |
| 合計ジャッジ時間 | 3,146 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
N,K = map(int,input().split())
lsD = list(map(lambda x:int(x)-1,input().split()))
# ループ見つける
used = [False]*(N)
loops = []
for i in range(N):
if used[i]:
continue
cnt = 0
now = i
while used[now] == False:
used[now] = True
cnt += 1
now = lsD[now]
loops.append(cnt-1)
aa = K-sum(loops)
if aa < 0:
print('NO')
elif aa % 2 == 0:
print('YES')
else:
print('NO')