結果

問題 No.482 あなたの名は
ユーザー 👑 tamatotamato
提出日時 2020-11-28 20:48:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 691 bytes
コンパイル時間 302 ms
コンパイル使用メモリ 87,600 KB
実行使用メモリ 109,856 KB
最終ジャッジ日時 2023-10-11 02:00:07
合計ジャッジ時間 6,498 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,628 KB
testcase_01 AC 68 ms
71,928 KB
testcase_02 AC 69 ms
71,880 KB
testcase_03 AC 71 ms
71,932 KB
testcase_04 AC 70 ms
71,696 KB
testcase_05 AC 69 ms
71,740 KB
testcase_06 AC 68 ms
71,684 KB
testcase_07 AC 72 ms
71,708 KB
testcase_08 AC 69 ms
71,968 KB
testcase_09 AC 70 ms
71,736 KB
testcase_10 AC 69 ms
71,836 KB
testcase_11 AC 71 ms
71,792 KB
testcase_12 AC 70 ms
71,580 KB
testcase_13 AC 69 ms
71,468 KB
testcase_14 AC 71 ms
71,712 KB
testcase_15 AC 126 ms
109,416 KB
testcase_16 AC 125 ms
109,448 KB
testcase_17 AC 124 ms
109,448 KB
testcase_18 AC 123 ms
109,292 KB
testcase_19 AC 123 ms
109,600 KB
testcase_20 AC 127 ms
109,592 KB
testcase_21 AC 124 ms
109,856 KB
testcase_22 AC 124 ms
109,172 KB
testcase_23 AC 124 ms
109,536 KB
testcase_24 AC 127 ms
109,248 KB
testcase_25 AC 135 ms
109,560 KB
testcase_26 AC 124 ms
109,304 KB
testcase_27 AC 126 ms
109,452 KB
testcase_28 AC 124 ms
109,440 KB
testcase_29 AC 109 ms
109,092 KB
testcase_30 AC 68 ms
71,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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