結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,004 KB
testcase_01 AC 4 ms
5,076 KB
testcase_02 AC 4 ms
4,852 KB
testcase_03 AC 5 ms
4,896 KB
testcase_04 AC 4 ms
4,824 KB
testcase_05 AC 5 ms
5,016 KB
testcase_06 AC 5 ms
4,852 KB
testcase_07 AC 5 ms
4,936 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 5 ms
4,908 KB
testcase_11 AC 5 ms
5,132 KB
testcase_12 AC 5 ms
5,072 KB
testcase_13 AC 5 ms
4,956 KB
testcase_14 AC 5 ms
5,000 KB
testcase_15 AC 141 ms
26,612 KB
testcase_16 AC 139 ms
26,724 KB
testcase_17 AC 138 ms
26,740 KB
testcase_18 AC 139 ms
26,668 KB
testcase_19 AC 140 ms
26,648 KB
testcase_20 AC 139 ms
26,716 KB
testcase_21 AC 139 ms
26,556 KB
testcase_22 AC 140 ms
26,504 KB
testcase_23 AC 140 ms
26,756 KB
testcase_24 AC 139 ms
26,552 KB
testcase_25 AC 141 ms
26,748 KB
testcase_26 AC 141 ms
26,496 KB
testcase_27 AC 141 ms
26,700 KB
testcase_28 AC 139 ms
26,612 KB
testcase_29 AC 129 ms
26,764 KB
testcase_30 AC 4 ms
4,828 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 abs($count - $k) % 2 == 0 ? "YES\n" : "NO\n";
0