結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
tanzaku
|
| 提出日時 | 2017-02-10 22:54:16 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 852 ms / 2,000 ms |
| コード長 | 833 bytes |
| コンパイル時間 | 3,688 ms |
| コンパイル使用メモリ | 78,140 KB |
| 実行使用メモリ | 56,868 KB |
| 最終ジャッジ日時 | 2024-12-29 20:19:56 |
| 合計ジャッジ時間 | 19,650 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
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));
}
}
tanzaku