結果
問題 | No.326 あみだますたー |
ユーザー |
![]() |
提出日時 | 2015-12-19 01:30:08 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 105 ms / 2,000 ms |
コード長 | 672 bytes |
コンパイル時間 | 436 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-11-07 23:18:51 |
合計ジャッジ時間 | 4,143 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 26 |
コンパイルメッセージ
Main.rb:11: warning: assigned but unused variable - s2 Syntax OK
ソースコード
n = gets.to_ik = gets.to_ia = Array.new(n)b = Array.new(n)x = Array.new(n)y = Array.new(n)n.times do |i|a[i] = i + 1endk.times dos1, s2 = gets.split.map(&:to_i)a[s1 - 1], a[s1] = a[s1], a[s1 - 1]endb = gets.split.map(&:to_i)n.times do |i|x[a[i] - 1] = i + 1y[b[i] - 1] = i + 1endres = Array.new(2).map{Array.new}n.times do |i|next if a[i] == y[i]j = 0while y[i] != a[j]j += 1endwhile i != ja[j], a[j - 1] = a[j - 1], a[j]res[0].push(j)res[1].push(j + 1)j -= 1endendputs res[0].lengthres[0].length.times do |i|print res[0][i], " ", res[1][i], "\n"end