結果

問題 No.482 あなたの名は
ユーザー shinwisteriashinwisteria
提出日時 2017-03-23 18:20:06
言語 Java19
(openjdk 21)
結果
TLE  
実行時間 -
コード長 639 bytes
コンパイル時間 5,124 ms
コンパイル使用メモリ 73,040 KB
実行使用メモリ 77,424 KB
最終ジャッジ日時 2023-09-19 06:42:24
合計ジャッジ時間 11,149 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
60,296 KB
testcase_01 AC 129 ms
55,744 KB
testcase_02 AC 128 ms
55,552 KB
testcase_03 AC 130 ms
55,696 KB
testcase_04 AC 130 ms
55,872 KB
testcase_05 AC 129 ms
55,588 KB
testcase_06 AC 129 ms
55,352 KB
testcase_07 AC 209 ms
56,576 KB
testcase_08 AC 200 ms
56,612 KB
testcase_09 AC 147 ms
55,748 KB
testcase_10 AC 172 ms
56,200 KB
testcase_11 AC 202 ms
56,208 KB
testcase_12 AC 209 ms
56,668 KB
testcase_13 AC 187 ms
55,796 KB
testcase_14 AC 181 ms
56,016 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Scanner;

public class YourName {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		long K = s.nextLong();
		ArrayList<Integer> D = new ArrayList<>();
		
		for(int i = 0;i<N;i++){
			D.add(s.nextInt());
		}
		s.close();
		for(int i : D){
			if(i > 0 && i != D.get(i-1)){
				while(true){
					int t = D.get(i-1);
					D.set(D.indexOf(i), 0);
					if(t == 0){
						break;
					}
					i = t;
					K--;
				}
			}
		}
		if(K > 0&&K%2 == 0){
			K = 0;
		}
		if(K == 0)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
	
}
0