結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
takeya_okino
|
| 提出日時 | 2017-07-09 18:22:24 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 860 ms / 2,000 ms |
| コード長 | 570 bytes |
| コンパイル時間 | 2,103 ms |
| コンパイル使用メモリ | 74,832 KB |
| 実行使用メモリ | 64,956 KB |
| 最終ジャッジ日時 | 2024-10-07 04:44:42 |
| 合計ジャッジ時間 | 17,969 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
long K = sc.nextLong();
int[] d = new int[N + 1];
for(int i = 1; i < N + 1; i++) {
d[i] = sc.nextInt();
}
long num = 0;
for(int i = 1; i < N + 1; i++) {
while(d[i] != i) {
int temp = d[i];
d[i] = d[d[i]];
d[temp] = temp;
num++;
}
}
String ans = "NO";
if(num <= K && (K - num) % 2 == 0) ans = "YES";
System.out.println(ans);
}
}
takeya_okino