結果

問題 No.482 あなたの名は
ユーザー kohei2019kohei2019
提出日時 2022-01-30 12:40:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 433 bytes
コンパイル時間 498 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 109,240 KB
最終ジャッジ日時 2023-09-02 01:31:37
合計ジャッジ時間 6,554 ms
ジャッジサーバーID
(参考情報)
judge11 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,252 KB
testcase_01 AC 72 ms
71,432 KB
testcase_02 AC 71 ms
71,476 KB
testcase_03 AC 72 ms
71,096 KB
testcase_04 AC 69 ms
71,248 KB
testcase_05 AC 71 ms
71,120 KB
testcase_06 AC 71 ms
71,244 KB
testcase_07 AC 72 ms
71,328 KB
testcase_08 AC 71 ms
71,480 KB
testcase_09 AC 72 ms
71,600 KB
testcase_10 AC 72 ms
71,148 KB
testcase_11 AC 72 ms
71,244 KB
testcase_12 AC 73 ms
71,324 KB
testcase_13 AC 73 ms
71,624 KB
testcase_14 AC 70 ms
71,240 KB
testcase_15 AC 157 ms
109,160 KB
testcase_16 AC 236 ms
109,220 KB
testcase_17 AC 143 ms
108,968 KB
testcase_18 AC 140 ms
108,988 KB
testcase_19 AC 144 ms
109,240 KB
testcase_20 AC 143 ms
108,920 KB
testcase_21 AC 141 ms
109,048 KB
testcase_22 AC 141 ms
109,036 KB
testcase_23 AC 141 ms
108,948 KB
testcase_24 AC 141 ms
109,044 KB
testcase_25 AC 144 ms
109,040 KB
testcase_26 AC 141 ms
109,092 KB
testcase_27 AC 140 ms
108,896 KB
testcase_28 AC 139 ms
109,144 KB
testcase_29 AC 126 ms
109,036 KB
testcase_30 AC 73 ms
71,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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')
0