結果
| 問題 |
No.326 あみだますたー
|
| コンテスト | |
| ユーザー |
yoza
|
| 提出日時 | 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_i
k = gets.to_i
amida = n.times.map {|i| i}
k.times do
x, y = gets.chomp.split.map {|i| i.to_i - 1}
amida[x], amida[y] = amida[y], amida[x]
end
a_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 == i
amida.delete_at(dest_index)
amida.insert(i, a)
dest_index.downto(i+1) {|k| b_list.push "#{k} #{k+1}"}
end
puts b_list.length
b_list.each {|b| puts b}
yoza