結果

問題 No.482 あなたの名は
ユーザー shinwisteriashinwisteria
提出日時 2017-03-21 10:56:10
言語 Java19
(openjdk 21)
結果
TLE  
実行時間 -
コード長 918 bytes
コンパイル時間 4,531 ms
コンパイル使用メモリ 80,424 KB
実行使用メモリ 77,420 KB
最終ジャッジ日時 2023-09-18 14:40:45
合計ジャッジ時間 11,382 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
60,168 KB
testcase_01 AC 128 ms
55,684 KB
testcase_02 AC 128 ms
55,552 KB
testcase_03 AC 126 ms
55,820 KB
testcase_04 AC 127 ms
56,280 KB
testcase_05 AC 128 ms
55,776 KB
testcase_06 AC 127 ms
56,004 KB
testcase_07 AC 212 ms
56,624 KB
testcase_08 AC 203 ms
56,472 KB
testcase_09 AC 145 ms
55,852 KB
testcase_10 AC 186 ms
55,684 KB
testcase_11 AC 201 ms
56,720 KB
testcase_12 AC 211 ms
56,532 KB
testcase_13 AC 200 ms
56,268 KB
testcase_14 AC 182 ms
56,292 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 {
	static ArrayList<Integer> list = new ArrayList<>();
	static StringBuilder cut = new StringBuilder();
	static long K;
	static int N;

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