結果

問題 No.482 あなたの名は
ユーザー cympfhcympfh
提出日時 2017-06-01 23:31:33
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 315 bytes
コンパイル時間 39 ms
コンパイル使用メモリ 11,932 KB
実行使用メモリ 31,616 KB
最終ジャッジ日時 2023-10-21 20:18:27
合計ジャッジ時間 5,974 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
17,656 KB
testcase_01 AC 93 ms
17,656 KB
testcase_02 AC 88 ms
17,656 KB
testcase_03 AC 88 ms
17,656 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 87 ms
17,656 KB
testcase_07 WA -
testcase_08 AC 87 ms
17,656 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 86 ms
17,656 KB
testcase_12 WA -
testcase_13 AC 87 ms
17,656 KB
testcase_14 AC 88 ms
17,656 KB
testcase_15 WA -
testcase_16 AC 211 ms
31,568 KB
testcase_17 WA -
testcase_18 AC 215 ms
31,568 KB
testcase_19 WA -
testcase_20 AC 211 ms
31,576 KB
testcase_21 AC 212 ms
31,568 KB
testcase_22 AC 214 ms
31,568 KB
testcase_23 AC 215 ms
31,568 KB
testcase_24 WA -
testcase_25 AC 209 ms
31,568 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 218 ms
31,568 KB
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, k = gets.chomp.split.map(&:to_i)
ds = gets.chomp.split.map { |d| d.to_i - 1 }
dict = [nil] * 200_000
ds.each_with_index do |d, i|
  dict[d] = i
end
n.times do |i|
  next if dict[i] == i
  j = dict[i]
  k = ds[i]
  ds[i] = i
  ds[j] = k
  dict[k] = j
  dict[i] = i
  k -= 1
end
puts k >= 0 && k.even? ? :YES : :NO
0