結果
| 問題 | No.482 あなたの名は |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-10 22:45:50 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 179 ms / 2,000 ms |
| コード長 | 416 bytes |
| 記録 | |
| コンパイル時間 | 152 ms |
| コンパイル使用メモリ | 77,372 KB |
| 最終ジャッジ日時 | 2025-12-03 23:04:49 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
n, k = map(int, raw_input().split())
d = map(lambda x: int(x)-1, raw_input().split())
f = [0 for _ in xrange(n)]
for i, e in enumerate(d):
f[e] = i
used = set()
hoge = []
x = 0
for i in xrange(n):
x = i
y = 0
while x not in used:
used.add(x)
x = f[x]
y += 1
if y > 0:
hoge.append(y)
x = sum(a-1 for a in hoge)
print "YES" if x % 2 == k % 2 and x <= k else "NO"