結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2017-02-11 10:21:44 |
言語 | Ruby (3.4.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 361 bytes |
コンパイル時間 | 175 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 27,136 KB |
最終ジャッジ日時 | 2024-12-29 12:00:47 |
合計ジャッジ時間 | 5,858 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 28 |
コンパイルメッセージ
Syntax OK
ソースコード
n,k = gets.split.map(&:to_i) d = gets.split.map(&:to_i) d = d.map { |v| v-1 } cnt = 0 n. n.times do |i| if d[i] == i next else t = d.index(i) tm = d[t] d[t] = d[i] d[i] = tm cnt += 1 end end if cnt == 0 if k.even? puts "YES" else puts "NO" end elsif cnt == k || (k - cnt) / 2 == 0 puts "YES" else puts "NO" end