結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-11 16:28:58 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 2,000 ms |
| コード長 | 455 bytes |
| コンパイル時間 | 626 ms |
| コンパイル使用メモリ | 102,380 KB |
| 実行使用メモリ | 13,168 KB |
| 最終ジャッジ日時 | 2024-06-12 22:59:57 |
| 合計ジャッジ時間 | 2,242 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string;
void main()
{
auto rd = readln.split, n = rd[0].to!int, k = rd[1].to!long;
auto d = readln.split.map!(to!int).map!"a-1".array;
auto v = new bool[](n), t = 0, r = 0;
foreach (i; 0..n) {
if (v[i]) continue;
auto j = i;
while (!v[j]) {
v[j] = true;
++r;
j = d[j];
}
t += r-1;
r = 0;
}
writeln(k >= t && (k-t)%2 == 0 ? "YES" : "NO");
}