結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-10 22:45:50 |
| 言語 | Python2 (2.7.18) |
| 結果 |
AC
|
| 実行時間 | 368 ms / 2,000 ms |
| コード長 | 416 bytes |
| コンパイル時間 | 542 ms |
| コンパイル使用メモリ | 7,072 KB |
| 実行使用メモリ | 35,576 KB |
| 最終ジャッジ日時 | 2024-12-29 20:16:49 |
| 合計ジャッジ時間 | 7,146 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / 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"