結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-10 22:37:20 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 222 ms / 2,000 ms |
| コード長 | 298 bytes |
| コンパイル時間 | 127 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 26,880 KB |
| 最終ジャッジ日時 | 2024-12-29 19:15:27 |
| 合計ジャッジ時間 | 6,207 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
コンパイルメッセージ
Syntax OK
ソースコード
n, k = gets.split.map(&:to_i)
a = gets.split.map{|x|x.to_i - 1}
idx = Array.new(n)
n.times do |i|
idx[a[i]] = i
end
cnt = 0
n.times do |i|
next if a[i] == i
idx[a[i]] = idx[i]
a[idx[i]] = a[i]
cnt += 1
end
if cnt > k || (k - cnt) % 2 == 1
puts "NO"
else
puts "YES"
end