結果

問題 No.482 あなたの名は
ユーザー 👑 KazunKazun
提出日時 2020-06-02 14:52:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 86,416 KB
実行使用メモリ 120,448 KB
最終ジャッジ日時 2023-08-15 15:07:43
合計ジャッジ時間 6,452 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
70,548 KB
testcase_01 AC 69 ms
70,796 KB
testcase_02 AC 63 ms
70,644 KB
testcase_03 AC 63 ms
70,680 KB
testcase_04 AC 65 ms
70,772 KB
testcase_05 AC 62 ms
70,680 KB
testcase_06 AC 63 ms
70,656 KB
testcase_07 AC 65 ms
70,892 KB
testcase_08 AC 66 ms
70,768 KB
testcase_09 AC 64 ms
70,764 KB
testcase_10 AC 63 ms
70,668 KB
testcase_11 AC 64 ms
70,828 KB
testcase_12 AC 65 ms
70,676 KB
testcase_13 AC 66 ms
70,724 KB
testcase_14 AC 65 ms
70,696 KB
testcase_15 AC 186 ms
120,064 KB
testcase_16 AC 152 ms
119,952 KB
testcase_17 AC 159 ms
120,080 KB
testcase_18 AC 150 ms
120,092 KB
testcase_19 AC 156 ms
120,448 KB
testcase_20 AC 157 ms
120,412 KB
testcase_21 AC 153 ms
120,184 KB
testcase_22 AC 153 ms
119,964 KB
testcase_23 AC 155 ms
120,244 KB
testcase_24 AC 155 ms
119,936 KB
testcase_25 AC 156 ms
120,116 KB
testcase_26 AC 155 ms
120,156 KB
testcase_27 AC 157 ms
119,980 KB
testcase_28 AC 153 ms
119,880 KB
testcase_29 AC 135 ms
115,936 KB
testcase_30 AC 61 ms
70,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(s):
    return int(s)-1

N,K=map(int,input().split())
D=list(map(f,input().split()))

U=set()
L=[]

for i in range(N):
    if i not in U:
        U.add(i)

        M=[i]
        x=i
        while True:
            x=D[x]

            if x!=i:
                U.add(x)
                M.append(x)
            else:
                L.append(M)
                break

S=0
for H in L:
    S+=len(H)-1

if S<=K and (K-S)%2==0:
    print("YES")
else:
    print("NO")
0