結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
tamato
|
| 提出日時 | 2020-11-28 20:48:29 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 104 ms / 2,000 ms |
| コード長 | 691 bytes |
| コンパイル時間 | 219 ms |
| コンパイル使用メモリ | 82,492 KB |
| 実行使用メモリ | 108,476 KB |
| 最終ジャッジ日時 | 2024-09-13 01:38:23 |
| 合計ジャッジ時間 | 4,648 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
mod = 1000000007
eps = 10**-9
def main():
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))
seen = [0] * (N+1)
M = 0
for i in range(1, N+1):
if seen[i]:
continue
p = A[i]
cnt = 0
seen[i] = 1
while True:
cnt += 1
if p != i:
seen[p] = 1
p = A[p]
else:
break
M += cnt - 1
if M > K:
print("NO")
else:
if (K - M) & 1:
print("NO")
else:
print("YES")
if __name__ == '__main__':
main()
tamato