結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2018-05-24 00:04:18 |
言語 | Perl (5.40.0) |
結果 |
AC
|
実行時間 | 127 ms / 2,000 ms |
コード長 | 333 bytes |
コンパイル時間 | 44 ms |
コンパイル使用メモリ | 5,760 KB |
実行使用メモリ | 28,928 KB |
最終ジャッジ日時 | 2024-06-28 16:35:49 |
合計ジャッジ時間 | 3,178 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
コンパイルメッセージ
Main.pl syntax OK
ソースコード
#!/usr/bin/env perl use strict; use warnings; my ($n, $k) = split / /, <>; my @d = split / /, <>; my $count = 0; for (my $i = 0; $i < $n;) { if ($i != $d[$i] - 1) { ($d[$i], $d[$d[$i] - 1]) = ($d[$d[$i] - 1], $d[$i]); $count++; } else { $i++; } } print $count <= $k && ($k - $count) % 2 == 0 ? "YES\n" : "NO\n";