結果

問題 No.482 あなたの名は
ユーザー uafr_csuafr_cs
提出日時 2017-02-10 22:34:35
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 850 bytes
コンパイル時間 2,354 ms
コンパイル使用メモリ 73,180 KB
実行使用メモリ 66,996 KB
最終ジャッジ日時 2023-08-27 22:26:16
合計ジャッジ時間 16,534 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,672 KB
testcase_01 AC 123 ms
55,704 KB
testcase_02 AC 130 ms
55,680 KB
testcase_03 AC 122 ms
55,896 KB
testcase_04 AC 122 ms
55,892 KB
testcase_05 AC 124 ms
55,704 KB
testcase_06 AC 122 ms
55,820 KB
testcase_07 AC 184 ms
56,324 KB
testcase_08 WA -
testcase_09 AC 141 ms
55,912 KB
testcase_10 AC 177 ms
55,952 KB
testcase_11 AC 179 ms
56,428 KB
testcase_12 WA -
testcase_13 AC 174 ms
56,112 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 679 ms
64,860 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 710 ms
64,580 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 704 ms
64,912 KB
testcase_24 AC 682 ms
64,924 KB
testcase_25 AC 732 ms
64,604 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 691 ms
65,264 KB
testcase_29 AC 734 ms
66,824 KB
testcase_30 AC 126 ms
55,820 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;
		}
		
		long min_times = 0;
		for(int i = 0; i < N; i++){
			if(swap[i] != i){
				final int tmp = swap[swap[i]];
				swap[swap[i]] = swap[i];
				swap[i] = tmp;
				
				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