結果

問題 No.482 あなたの名は
ユーザー motimoti
提出日時 2018-05-24 00:04:18
言語 Perl
(5.38.2)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 333 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 5,328 KB
実行使用メモリ 26,784 KB
最終ジャッジ日時 2023-09-11 02:04:21
合計ジャッジ時間 3,634 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,076 KB
testcase_01 AC 5 ms
4,800 KB
testcase_02 AC 4 ms
5,004 KB
testcase_03 AC 5 ms
4,796 KB
testcase_04 AC 5 ms
5,000 KB
testcase_05 AC 5 ms
5,072 KB
testcase_06 AC 5 ms
4,824 KB
testcase_07 AC 5 ms
5,048 KB
testcase_08 AC 5 ms
5,092 KB
testcase_09 AC 5 ms
5,056 KB
testcase_10 AC 5 ms
5,064 KB
testcase_11 AC 5 ms
4,812 KB
testcase_12 AC 5 ms
5,096 KB
testcase_13 AC 5 ms
4,892 KB
testcase_14 AC 5 ms
4,796 KB
testcase_15 AC 137 ms
26,784 KB
testcase_16 AC 141 ms
26,548 KB
testcase_17 AC 137 ms
26,672 KB
testcase_18 AC 138 ms
26,744 KB
testcase_19 AC 138 ms
26,524 KB
testcase_20 AC 139 ms
26,724 KB
testcase_21 AC 140 ms
26,708 KB
testcase_22 AC 137 ms
26,716 KB
testcase_23 AC 141 ms
26,612 KB
testcase_24 AC 138 ms
26,592 KB
testcase_25 AC 139 ms
26,728 KB
testcase_26 AC 140 ms
26,616 KB
testcase_27 AC 140 ms
26,680 KB
testcase_28 AC 142 ms
26,612 KB
testcase_29 AC 129 ms
26,608 KB
testcase_30 AC 5 ms
5,004 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/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";
0