結果
問題 | No.326 あみだますたー |
ユーザー |
![]() |
提出日時 | 2016-03-22 23:06:41 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 104 ms / 2,000 ms |
コード長 | 582 bytes |
コンパイル時間 | 193 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-11-07 23:28:03 |
合計ジャッジ時間 | 4,119 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 26 |
コンパイルメッセージ
Syntax OK
ソースコード
class Yukicoderdef initializen = gets.to_ik = gets.to_iarray = (1..n).to_ak.times doi, j = gets.split.map(&:to_i)array[i-1], array[j-1] = array[j-1], array[i-1]endlist = gets.split.map(&:to_i)list = (1..n).map{|i| list.index(i)+1}swap_list = []0.upto(n-1) do |i|j = array.index(list[i])while list[i] != array[i]array[j-1], array[j] = array[j], array[j-1]swap_list << "#{j} #{j+1}"j -= 1endendputs swap_list.sizeputs swap_listendendYukicoder.new