結果

問題 No.482 あなたの名は
ユーザー htensaihtensai
提出日時 2020-02-05 14:06:25
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 693 bytes
コンパイル時間 2,121 ms
コンパイル使用メモリ 74,700 KB
実行使用メモリ 68,304 KB
最終ジャッジ日時 2023-10-23 18:17:14
合計ジャッジ時間 17,350 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
57,160 KB
testcase_01 AC 114 ms
56,268 KB
testcase_02 AC 125 ms
57,212 KB
testcase_03 AC 126 ms
57,404 KB
testcase_04 AC 128 ms
57,564 KB
testcase_05 AC 127 ms
57,480 KB
testcase_06 AC 127 ms
55,584 KB
testcase_07 AC 176 ms
57,624 KB
testcase_08 WA -
testcase_09 AC 142 ms
57,616 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 176 ms
57,552 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 670 ms
67,216 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 686 ms
67,672 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 677 ms
67,180 KB
testcase_24 AC 673 ms
68,012 KB
testcase_25 AC 689 ms
67,356 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 666 ms
66,936 KB
testcase_29 AC 725 ms
68,056 KB
testcase_30 AC 129 ms
57,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        int[] arr = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 1; i <= n; i++) {
            if (i != arr[i]) {
                int x = arr[i];
                arr[i] = arr[x];
                arr[x] = x;
                count++;
            }
        }
        if (k % 2 == count % 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}
0