結果

問題 No.482 あなたの名は
ユーザー uafr_csuafr_cs
提出日時 2017-02-10 22:55:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 708 ms / 2,000 ms
コード長 1,064 bytes
コンパイル時間 4,842 ms
コンパイル使用メモリ 74,972 KB
実行使用メモリ 68,704 KB
最終ジャッジ日時 2023-08-28 16:14:25
合計ジャッジ時間 16,242 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,664 KB
testcase_01 AC 125 ms
55,748 KB
testcase_02 AC 123 ms
55,848 KB
testcase_03 AC 126 ms
55,496 KB
testcase_04 AC 124 ms
56,100 KB
testcase_05 AC 125 ms
55,672 KB
testcase_06 AC 125 ms
55,820 KB
testcase_07 AC 187 ms
56,308 KB
testcase_08 AC 183 ms
57,676 KB
testcase_09 AC 145 ms
55,916 KB
testcase_10 AC 182 ms
55,732 KB
testcase_11 AC 185 ms
56,028 KB
testcase_12 AC 188 ms
55,944 KB
testcase_13 AC 181 ms
55,840 KB
testcase_14 AC 177 ms
55,824 KB
testcase_15 AC 702 ms
64,980 KB
testcase_16 AC 679 ms
64,400 KB
testcase_17 AC 685 ms
64,512 KB
testcase_18 AC 656 ms
64,476 KB
testcase_19 AC 666 ms
64,932 KB
testcase_20 AC 708 ms
64,752 KB
testcase_21 AC 646 ms
64,712 KB
testcase_22 AC 645 ms
64,532 KB
testcase_23 AC 652 ms
64,760 KB
testcase_24 AC 655 ms
65,056 KB
testcase_25 AC 674 ms
64,264 KB
testcase_26 AC 690 ms
64,520 KB
testcase_27 AC 688 ms
64,792 KB
testcase_28 AC 682 ms
64,892 KB
testcase_29 AC 704 ms
68,704 KB
testcase_30 AC 124 ms
55,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final long K = sc.nextLong();
		
		int[] swap = new int[N];
		for(int i = 0; i < N; i++){
			swap[i] = sc.nextInt() - 1;
		}
		int[] rev_swap = new int[N];
		for(int i = 0; i < N; i++){
			rev_swap[swap[i]] = i;
		}
		
		long min_times = 0;
		for(int i = 0; i < N; i++){
			if(swap[i] != i){
				final int swap_index = rev_swap[i];
				//System.out.println(i + " " + swap[i] + " " + swap_index);
				rev_swap[swap[i]] = swap_index;
				rev_swap[i] = i;
				swap[swap_index] = swap[i];
				swap[i] = i;
				
				min_times++;
			}
			//System.out.println(Arrays.toString(swap));
		}
		
		if(min_times > K || (K - min_times) % 2 != 0){
			System.out.println("NO");
		}else{
			System.out.println("YES");
		}
	}
}
0