結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-30 12:40:10 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 124 ms / 2,000 ms |
| コード長 | 433 bytes |
| コンパイル時間 | 335 ms |
| コンパイル使用メモリ | 81,908 KB |
| 実行使用メモリ | 114,048 KB |
| 最終ジャッジ日時 | 2024-06-11 08:11:26 |
| 合計ジャッジ時間 | 4,580 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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')