結果

問題 No.482 あなたの名は
ユーザー tanzakutanzaku
提出日時 2017-02-10 22:54:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 664 ms / 2,000 ms
コード長 833 bytes
コンパイル時間 4,069 ms
コンパイル使用メモリ 75,100 KB
実行使用メモリ 66,268 KB
最終ジャッジ日時 2023-08-28 16:14:05
合計ジャッジ時間 17,511 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,964 KB
testcase_01 AC 118 ms
55,640 KB
testcase_02 AC 117 ms
55,708 KB
testcase_03 AC 117 ms
55,496 KB
testcase_04 AC 116 ms
55,656 KB
testcase_05 AC 118 ms
55,708 KB
testcase_06 AC 118 ms
55,964 KB
testcase_07 AC 173 ms
56,324 KB
testcase_08 AC 168 ms
55,756 KB
testcase_09 AC 143 ms
55,444 KB
testcase_10 AC 165 ms
56,208 KB
testcase_11 AC 164 ms
56,036 KB
testcase_12 AC 177 ms
56,868 KB
testcase_13 AC 168 ms
56,368 KB
testcase_14 AC 161 ms
55,640 KB
testcase_15 AC 640 ms
65,056 KB
testcase_16 AC 628 ms
64,844 KB
testcase_17 AC 627 ms
64,328 KB
testcase_18 AC 644 ms
64,552 KB
testcase_19 AC 634 ms
64,532 KB
testcase_20 AC 664 ms
66,268 KB
testcase_21 AC 627 ms
64,204 KB
testcase_22 AC 638 ms
64,456 KB
testcase_23 AC 641 ms
62,992 KB
testcase_24 AC 641 ms
64,652 KB
testcase_25 AC 648 ms
64,208 KB
testcase_26 AC 663 ms
62,912 KB
testcase_27 AC 639 ms
64,816 KB
testcase_28 AC 641 ms
64,248 KB
testcase_29 AC 664 ms
66,268 KB
testcase_30 AC 117 ms
55,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class _482 {
	public static void main(String[] args) throws IOException {
		new _482().solve();
	}

	void solve() throws IOException {
		try (final Scanner in = new Scanner(System.in)) {
			int n = in.nextInt();
			long k = in.nextLong();
			int[] D = new int[n];
			for (int i = 0; i < n; i++) {
				D[i] = in.nextInt() - 1;
			}
			boolean[] vis = new boolean[n];
			for (int i = 0; i < n; i++) if (!vis[i]) {
				int c = 1;
				for (int j = D[i]; j != i; j = D[j], c++) vis[j] = true;
				k -= c - 1;
			}
			System.out.println(k >= 0 && k % 2 == 0 ? "YES" : "NO");
		}
	}
	
	// for debug
	static void dump(Object... o) {
		System.err.println(Arrays.deepToString(o));
	}
}
0