結果
問題 | No.326 あみだますたー |
ユーザー |
![]() |
提出日時 | 2015-12-19 21:51:32 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 129 ms / 2,000 ms |
コード長 | 512 bytes |
コンパイル時間 | 216 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 12,416 KB |
最終ジャッジ日時 | 2024-12-26 05:58:01 |
合計ジャッジ時間 | 5,130 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 26 |
コンパイルメッセージ
Syntax OK
ソースコード
n = gets.to_ik = gets.to_iamida = n.times.map {|i| i}k.times dox, y = gets.chomp.split.map {|i| i.to_i - 1}amida[x], amida[y] = amida[y], amida[x]enda_list = Array.new(n)gets.chomp.split.each_with_index {|a, i| a_list[a.to_i - 1] = i}b_list = []a_list.each_with_index do |a, i|dest_index = amida.find_index(a)next if dest_index == iamida.delete_at(dest_index)amida.insert(i, a)dest_index.downto(i+1) {|k| b_list.push "#{k} #{k+1}"}endputs b_list.lengthb_list.each {|b| puts b}